From b5b840d230443aa38b045cf58a3b6a59dfc919b1 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 2 Feb 2021 11:31:40 +0100 Subject: [PATCH] using process choice in template works in principle now --- evapp/templates/evapp/employee_form.html | 2 +- evapp/views.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/evapp/templates/evapp/employee_form.html b/evapp/templates/evapp/employee_form.html index 3ec09f9..8f03661 100644 --- a/evapp/templates/evapp/employee_form.html +++ b/evapp/templates/evapp/employee_form.html @@ -45,7 +45,7 @@ {% endif %}

- {% if wizard.steps.step1 == 5 %} + {% if wizard.steps.step1 == 5 or choice == 'CHANGE' %} {% for key, value in data.items %} {{ key }}: {{ value }}

{% endfor %} diff --git a/evapp/views.py b/evapp/views.py index 75705d2..7fe8fbb 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -23,12 +23,19 @@ class EvaFormView(CookieWizardView): template_name = 'evapp/employee_form.html' form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm] instance = None + choice = 'IN' + + def get_all_cleaned_data(self): + data = super().get_all_cleaned_data() + del data['choice'] + return data # we need this to display all the data in the last step def get_context_data(self, form, **kwargs): context = super().get_context_data(form=form, **kwargs) - if (self.steps.current == 5): - context.update({'data': self.beautify_data(self.get_all_cleaned_data())}) + if (self.steps.current == 5 or self.choice == 'CHANGE'): + context.update({'data': self.beautify_data(self.get_all_cleaned_data()), + 'choice' : self.choice}) return context #this makes shure, that we use the same model instance for all steps @@ -63,6 +70,7 @@ class EvaFormView(CookieWizardView): prev_data = self.get_cleaned_data_for_step('0') choice = prev_data.get('choice') print(f'choice detection: {TYPE_CHOICES[choice]}') + self.choice = choice if choice == 'CHANGE': print("process choosen: CHANGE") form = ChangeForm(data)