fixed context data in last step

This commit is contained in:
Benni Bärmann 2021-01-14 12:44:04 +01:00
parent f6bdaa01d5
commit 3a3b7f25cb
3 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,4 @@
dataloop
{% for key, value in data.items %} {% for key, value in data.items %}
{{ key }}: {{ value }} {{ key }}: {{ value }}
{% endfor %} {% endfor %}

View File

@ -45,7 +45,11 @@
{% endif %} {% endif %}
</p> </p>
</h2> </h2>
{% if wizard.steps.step1 == 5 %}
{% for key, value in data.items %}
{{ key }}: {{ value }}<p>
{% endfor %}
{% endif %}
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
<table> <table>

View File

@ -49,10 +49,18 @@ class EvaFormView(CookieWizardView):
template_name = 'evapp/employee_form.html' template_name = 'evapp/employee_form.html'
form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm] form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm]
instance = None instance = None
data = {}
# form_class = EmployeeForm # form_class = EmployeeForm
def get_success_url(self): def get_context_data(self, form, **kwargs):
return reverse('success') context = super().get_context_data(form=form, **kwargs)
# self.data.update(form.cleaned_data)
# if self.steps.current == '5':
context.update({'data': self.get_all_cleaned_data()})
return context
# def get_success_url(self):
# return reverse('success')
#this makes shure, that we use the same model instance for all steps #this makes shure, that we use the same model instance for all steps
def get_form_instance(self,step): def get_form_instance(self,step):
@ -66,10 +74,10 @@ class EvaFormView(CookieWizardView):
print(self.instance_dict) print(self.instance_dict)
for form in form_list: for form in form_list:
form.save() form.save()
form_data = [form.cleaned_data for form in form_list] # form_data = [form.cleaned_data for form in form_list]
print(form_data) # print(form_data)
for dep in MAILS: for dep in MAILS:
send_mail_to_department(dep, form_data) send_mail_to_department(dep, self.get_all_cleaned_data())
return HttpResponseRedirect('success') return HttpResponseRedirect('success')
# return super().form_valid(form) # return super().form_valid(form)