Skip to content

Commit

Permalink
Fix a proxy model bug related to ad-free
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer committed Jul 17, 2018
1 parent 6dbf1c1 commit 531b1d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions readthedocs/projects/models.py
Expand Up @@ -884,6 +884,7 @@ class Meta:

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',
Expand All @@ -900,6 +901,11 @@ def save(self, *args, **kwargs):
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):
Expand Down

0 comments on commit 531b1d8

Please sign in to comment.