Skip to content
Snippets Groups Projects
Commit 2727a6eb authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add fields from LDAP to registration form, advances #15.

parent 09c97ecd
No related branches found
No related tags found
1 merge request!20Add dynamic fields to event registration
......@@ -131,8 +131,21 @@ class EventRegisterForm(forms.Form):
def __init__(self, project, *args, **kwargs):
super(EventRegisterForm, self).__init__(*args, **kwargs)
self.fields['voucher_code'].validators.append(is_valid_voucher_for(project.cn))
for field in project.registration_fields:
label, help_text, *choices = field.split('|')
var = re.sub(r'\W|^(?=\d)', '_', label)
if choices:
choices_map = [(re.sub(r'\W|^(?=\d)', '_', choice), choice) for choice in choices]
field_attr = forms.ChoiceField(label=label, help_text=help_text, choices=choices_map)
else:
field_attr = forms.CharField(label=label, help_text=help_text)
self.fields[var] = field_attr
class EventFeedbackForm(forms.Form):
comment_private = forms.CharField(required=False, label=_('Kommentar für das Team'),
help_text=_('Dieser Kommentar ist nur für das Team. Du kannst hier alles aufschreiben, was du uns noch als Feedback mitteilen möchtest.'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment