diff --git a/input/forms.py b/input/forms.py index b8fb181..019d773 100644 --- a/input/forms.py +++ b/input/forms.py @@ -28,6 +28,7 @@ class VolunteerForm(ModelForm): fields = '__all__' class LibraryForm(ModelForm): + class Meta: model = Library exclude = ('realname', 'email', 'username', 'type') diff --git a/input/models.py b/input/models.py index 59efd1e..b7d0ef1 100644 --- a/input/models.py +++ b/input/models.py @@ -52,7 +52,6 @@ class Library(Grant): library = models.CharField(max_length=200) duration = models.CharField(max_length=100) - def __str__(self): return self.library diff --git a/input/views.py b/input/views.py index 9c98999..51ad60c 100644 --- a/input/views.py +++ b/input/views.py @@ -62,11 +62,15 @@ class ExternView(CookieWizardView): if step == '1': prev_data = self.get_cleaned_data_for_step('0') - if prev_data.get('choice') == 'IFG': + choice = prev_data.get('choice') + if choice == 'IFG': print ('IFG detected!') form = IFGForm(data) - else: + elif choice in ('BIB', 'SOFT', 'ELIT'): + print ('one of the famous three detected!') form = LibraryForm(data) + else: + print('ERROR! UNKNOWN FORMTYPE!') else: form = super().get_form(step, data, files) return form @@ -87,6 +91,8 @@ class ExternView(CookieWizardView): form.realname = data['realname'] form.username = data['username'] form.email = data['email'] + if data['choice'] in ('BIB', 'ELIT', 'SOFT'): + form.type = data['choice'] form.save() # we need to send the following mails here: