change process working, in process is still missing last step.

This commit is contained in:
Benni Bärmann 2021-02-03 14:42:55 +01:00
parent 3f9a84a3f2
commit 49718e66ff
3 changed files with 22 additions and 8 deletions

View File

@ -45,7 +45,7 @@
{% endif %} {% endif %}
</p> </p>
</h2> </h2>
{% 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 %} {% for key, value in data.items %}
{{ key }}: {{ value }}<p> {{ key }}: {{ value }}<p>
{% endfor %} {% endfor %}

View File

@ -1,11 +1,12 @@
from django.urls import path from django.urls import path
from .views import EvaFormView, success, long_process from .views import EvaFormView, success, long_process, change_process
urlpatterns = [ urlpatterns = [
path('', EvaFormView.as_view(condition_dict = {'2': long_process, path('', EvaFormView.as_view(condition_dict = {'1': long_process,
'3': long_process,}), '2': long_process,
#'4': long_process,}), '3': long_process,
'4': change_process,}),
name='evaform'), name='evaform'),
path('success', success, name='success') path('success', success, name='success')
] ]

View File

@ -25,12 +25,18 @@ def long_process(wizard):
#print(f"gathering data for step {step}") #print(f"gathering data for step {step}")
data = wizard.get_cleaned_data_for_step('0') or {} data = wizard.get_cleaned_data_for_step('0') or {}
print(data) print(data)
if data.get('choice') == 'IN': if data.get('choice') != 'CHANGE':
wizard.set_choice('IN')
print('PROZESS IN') print('PROZESS IN')
return True return True
else: else:
wizard.set_choice('CHANGE')
print('PROZESS NOT IN') print('PROZESS NOT IN')
return False return False
def change_process(wizard):
print('CHANGE PROZESS')
return not long_process(wizard)
# elif step < 3: # elif step < 3:
# return True # return True
# elif step == 4: # elif step == 4:
@ -41,14 +47,21 @@ def long_process(wizard):
class EvaFormView(CookieWizardView): 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, ChangeForm, DummyForm]
instance = None instance = None
choice = 'IN' 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 # this deletes data which is only used temporary and is not in the modell
def get_all_cleaned_data(self): def get_all_cleaned_data(self):
data = super().get_all_cleaned_data() data = super().get_all_cleaned_data()
del data['choice'] print("delete CHOICE FROM DATA")
if 'choice' in data:
del data['choice']
return data return data
# we need this to display all the data in the last step # we need this to display all the data in the last step