core: make SignUpForm’s fields readonly if there is an initial value

This commit is contained in:
Jens Langhammer 2018-12-10 15:26:53 +01:00
parent 7f2bae4c2c
commit 111b0ec4fb
1 changed files with 4 additions and 0 deletions

View File

@ -50,6 +50,10 @@ class SignUpForm(forms.Form):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# All fields which have initial data supplied are set to read only
if 'initial' in kwargs:
for field, _ in kwargs.get('initial').items():
self.fields[field].widget.attrs['readonly'] = 'readonly'
# TODO: Dynamically add captcha here # TODO: Dynamically add captcha here
# if not Setting.get_bool('recaptcha:enabled'): # if not Setting.get_bool('recaptcha:enabled'):
# self.fields.pop('captcha') # self.fields.pop('captcha')