|
|
@ -3,7 +3,7 @@ from django.forms import modelformset_factory |
|
|
|
from django.http import HttpResponse |
|
|
|
from formtools.wizard.views import CookieWizardView |
|
|
|
|
|
|
|
from .forms import ProjectForm, VolunteerForm, LibraryForm |
|
|
|
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm |
|
|
|
from .models import Project |
|
|
|
|
|
|
|
def intern(request): |
|
|
@ -34,6 +34,13 @@ class ExternView(CookieWizardView): |
|
|
|
template_name = "input/extern.html" |
|
|
|
form_list = [VolunteerForm, LibraryForm] |
|
|
|
|
|
|
|
def process_step(self, form): |
|
|
|
if form.cleaned_data.get('choice') == 'IFG': |
|
|
|
print ('IFG detected!') |
|
|
|
self.form_list = [VolunteerForm, IFGForm] |
|
|
|
print('leaving process_step()') |
|
|
|
return self.get_form_step_data(form) |
|
|
|
|
|
|
|
def done(self, form_list, **kwargs): |
|
|
|
print('ExternView.done() reached') |
|
|
|
# gather data from all forms |
|
|
@ -41,9 +48,11 @@ class ExternView(CookieWizardView): |
|
|
|
for form in form_list: |
|
|
|
data = {**data, **form.cleaned_data} |
|
|
|
print(data) |
|
|
|
|
|
|
|
# write data to database |
|
|
|
form = form.save(commit=False) |
|
|
|
# this is ugly code. how can we copy this without explicit writing? |
|
|
|
# i found no way to access the ModelForm.Meta.exclude-array |
|
|
|
form.realname = data['realname'] |
|
|
|
form.username = data['username'] |
|
|
|
form.email = data['email'] |
|
|
|