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

View file

@ -50,6 +50,10 @@ class SignUpForm(forms.Form):
def __init__(self, *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
# if not Setting.get_bool('recaptcha:enabled'):
# self.fields.pop('captcha')