Fix a proxy model bug related to ad-free

humitos/git/unicode-branches
David Fischer 2018-07-17 12:25:32 -07:00
parent 6dbf1c1b2e
commit 531b1d82f2
No known key found for this signature in database
GPG Key ID: F0C9B0ADA737AB60
1 changed files with 6 additions and 0 deletions

View File

@ -884,6 +884,7 @@ class APIProject(Project):
def __init__(self, *args, **kwargs):
self.features = kwargs.pop('features', [])
self.ad_free = (not kwargs.pop('show_advertising', True))
# These fields only exist on the API return, not on the model, so we'll
# remove them to avoid throwing exceptions due to unexpected fields
for key in ['users', 'resource_uri', 'absolute_url', 'downloads',
@ -900,6 +901,11 @@ class APIProject(Project):
def has_feature(self, feature_id):
return feature_id in self.features
@property
def show_advertising(self):
"""Whether this project is ad-free (don't access the database)"""
return not self.ad_free
@python_2_unicode_compatible
class ImportedFile(models.Model):