More Work on InternView. Basic HonoraryCertificate works
This commit is contained in:
parent
a7e8b9a19a
commit
93d1f2f9d5
|
@ -75,7 +75,45 @@ class InternView(CookieWizardView):
|
||||||
'''This View is for the WMDE-employees only'''
|
'''This View is for the WMDE-employees only'''
|
||||||
|
|
||||||
template_name = 'input/extern.html'
|
template_name = 'input/extern.html'
|
||||||
form_list = [InternForm, HonoraryCertificateForm]
|
form_list = [InternForm, ProjectForm]
|
||||||
|
|
||||||
|
def get_form(self, step=None, data=None, files=None):
|
||||||
|
if step is None:
|
||||||
|
step = self.steps.current
|
||||||
|
print ("get_form() step " + step)
|
||||||
|
|
||||||
|
if step == '1':
|
||||||
|
prev_data = self.get_cleaned_data_for_step('0')
|
||||||
|
choice = prev_data.get('choice')
|
||||||
|
if choice == 'HON':
|
||||||
|
print ('Ehrenamtsbescheinigung detected!')
|
||||||
|
form = HonoraryCertificateForm(data)
|
||||||
|
else:
|
||||||
|
print('ERROR! UNKNOWN FORMTYPE!')
|
||||||
|
else:
|
||||||
|
form = super().get_form(step, data, files)
|
||||||
|
return form
|
||||||
|
|
||||||
|
def done(self, form_list, **kwargs):
|
||||||
|
print('ExternView.done() reached')
|
||||||
|
# gather data from all forms
|
||||||
|
data = {}
|
||||||
|
for form in form_list:
|
||||||
|
data = {**data, **form.cleaned_data}
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
# write data to database
|
||||||
|
form = form.save(commit=False)
|
||||||
|
# we have to copy the data from the first form here
|
||||||
|
# this is ugly code. how can we copy this without explicit writing?
|
||||||
|
# i found no way to access the ModelForm.Meta.exclude-tupel
|
||||||
|
form.realname = data['realname']
|
||||||
|
form.username = data['username']
|
||||||
|
form.email = data['email']
|
||||||
|
form.save()
|
||||||
|
|
||||||
|
return done(self.request)
|
||||||
|
|
||||||
|
|
||||||
class ExternView(CookieWizardView):
|
class ExternView(CookieWizardView):
|
||||||
'''This View is for Volunteers'''
|
'''This View is for Volunteers'''
|
||||||
|
@ -158,6 +196,3 @@ class ExternView(CookieWizardView):
|
||||||
return HttpResponse('Invalid header found.')
|
return HttpResponse('Invalid header found.')
|
||||||
|
|
||||||
return done(self.request)
|
return done(self.request)
|
||||||
# return render(self.request, 'saved', {
|
|
||||||
# 'form_data': [form.cleaned_data for form in form_list],
|
|
||||||
# })
|
|
||||||
|
|
Loading…
Reference in New Issue