From 49718e66fff2ed243ff86abb13a7067e39597480 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 3 Feb 2021 14:42:55 +0100 Subject: [PATCH] change process working, in process is still missing last step. --- evapp/templates/evapp/employee_form.html | 2 +- evapp/urls.py | 9 +++++---- evapp/views.py | 19 ++++++++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/evapp/templates/evapp/employee_form.html b/evapp/templates/evapp/employee_form.html index 78a29b6..da8706a 100644 --- a/evapp/templates/evapp/employee_form.html +++ b/evapp/templates/evapp/employee_form.html @@ -45,7 +45,7 @@ {% endif %}

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

{% endfor %} diff --git a/evapp/urls.py b/evapp/urls.py index 740a5f2..45c9624 100644 --- a/evapp/urls.py +++ b/evapp/urls.py @@ -1,11 +1,12 @@ from django.urls import path -from .views import EvaFormView, success, long_process +from .views import EvaFormView, success, long_process, change_process urlpatterns = [ - path('', EvaFormView.as_view(condition_dict = {'2': long_process, - '3': long_process,}), - #'4': long_process,}), + path('', EvaFormView.as_view(condition_dict = {'1': long_process, + '2': long_process, + '3': long_process, + '4': change_process,}), name='evaform'), path('success', success, name='success') ] diff --git a/evapp/views.py b/evapp/views.py index a3b7b06..deb129d 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -25,12 +25,18 @@ def long_process(wizard): #print(f"gathering data for step {step}") data = wizard.get_cleaned_data_for_step('0') or {} print(data) - if data.get('choice') == 'IN': + if data.get('choice') != 'CHANGE': + wizard.set_choice('IN') print('PROZESS IN') return True else: + wizard.set_choice('CHANGE') print('PROZESS NOT IN') return False + +def change_process(wizard): + print('CHANGE PROZESS') + return not long_process(wizard) # elif step < 3: # return True # elif step == 4: @@ -41,14 +47,21 @@ def long_process(wizard): class EvaFormView(CookieWizardView): template_name = 'evapp/employee_form.html' - form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm] + form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, ChangeForm, DummyForm] instance = None choice = 'IN' + # maybe we dont need this, if *_process() would be class methods, + # but unsure if this would work fine with the entries in urls.py + def set_choice(self, c): + self.choice = c + # this deletes data which is only used temporary and is not in the modell def get_all_cleaned_data(self): data = super().get_all_cleaned_data() - del data['choice'] + print("delete CHOICE FROM DATA") + if 'choice' in data: + del data['choice'] return data # we need this to display all the data in the last step