mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
forms.py: Add the dynamic field in __init__
If we add the field like this, we can control its existence in tests. In other case, since classes are compiled once, even if we set TERMS_OF_SERVICE to False in tests, terms field would still continue to exist in the form class.
This commit is contained in:
@@ -63,8 +63,11 @@ class RegistrationForm(forms.Form):
|
|||||||
(Realm.CORPORATE, 'Corporate')),
|
(Realm.CORPORATE, 'Corporate')),
|
||||||
initial=Realm.COMMUNITY, required=False)
|
initial=Realm.COMMUNITY, required=False)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
# type: (*Any, **Any) -> None
|
||||||
|
super(RegistrationForm, self).__init__(*args, **kwargs)
|
||||||
if settings.TERMS_OF_SERVICE:
|
if settings.TERMS_OF_SERVICE:
|
||||||
terms = forms.BooleanField(required=True)
|
self.fields['terms'] = forms.BooleanField(required=True)
|
||||||
|
|
||||||
def clean_full_name(self):
|
def clean_full_name(self):
|
||||||
# type: () -> Text
|
# type: () -> Text
|
||||||
|
|||||||
Reference in New Issue
Block a user