Add `allows_promos` field if necessary instead of removing it
@@ -27,9 +27,9 @@ class UserProfileForm(forms.ModelForm):
class Meta(object):
model = UserProfile
# Don't allow users edit someone else's user page
- fields = ['first_name', 'last_name', 'homepage', 'allow_ads']
- if not settings.USE_PROMOS:
- del fields[fields.index('allow_ads')]
+ fields = ['first_name', 'last_name', 'homepage']
+ if settings.USE_PROMOS:
+ fields.append('allow_ads')
def __init__(self, *args, **kwargs):
super(UserProfileForm, self).__init__(*args, **kwargs)
