diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-08-18 15:15:36 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-08-18 15:15:36 +0200 |
commit | 37d22731c48221edf8eccaddbc2b87ae332f8fca (patch) | |
tree | c8a15c04bff6bf1496afe217ca00684ceaed285a /ishtar_common/wizards.py | |
parent | 601bcd199a5078ad951f3bce77edc0f1f940a790 (diff) | |
download | Ishtar-37d22731c48221edf8eccaddbc2b87ae332f8fca.tar.bz2 Ishtar-37d22731c48221edf8eccaddbc2b87ae332f8fca.zip |
PEP8 and formating
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index c01ef5301..af236504c 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -50,8 +50,9 @@ class MultiValueDict(BaseMultiValueDict): class Wizard(NamedUrlWizardView): model = None label = '' - modification = None # True when the wizard modify an item - storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' + modification = None # True when the wizard modify an item + storage_name = \ + 'django.contrib.formtools.wizard.storage.session.SessionStorage' translated_keys = ['title'] wizard_done_template = 'ishtar/wizard/wizard_done.html' wizard_done_window = '' @@ -67,7 +68,7 @@ class Wizard(NamedUrlWizardView): if not cond: return False return True - #TODO: to be check + # TODO: to be check if not hasattr(self.request.user, 'ishtaruser'): return False return self.request.user.ishtaruser.has_right(('administrator', @@ -98,8 +99,9 @@ class Wizard(NamedUrlWizardView): templates = ['ishtar/wizard/default_wizard.html'] current_step = self.steps.current wizard_templates = dict([ - (key % {'url_name':self.url_name}, self.wizard_templates[key]) - for key in self.wizard_templates]) + (key % {'url_name': self.url_name}, self.wizard_templates[key]) + for key in self.wizard_templates + ]) if current_step in wizard_templates: templates = [wizard_templates[current_step]] + templates elif current_step == self.steps.last: @@ -112,9 +114,9 @@ class Wizard(NamedUrlWizardView): self.request.session['CURRENT_ACTION'] = self.get_wizard_name() step = self.steps.first current_step = self.steps.current - context.update({'current_step':self.form_list[current_step], - 'wizard_label':self.label, - 'current_object':self.get_current_object()}) + context.update({'current_step': self.form_list[current_step], + 'wizard_label': self.label, + 'current_object': self.get_current_object()}) if step == current_step: return context previous_steps, next_steps, previous_step_counter = [], [], 0 @@ -128,8 +130,8 @@ class Wizard(NamedUrlWizardView): if previous_step_counter >= len(self.steps): break step = self.steps.all[previous_step_counter] - context.update({'previous_steps':previous_steps, - 'previous_step_counter':previous_step_counter}) + context.update({'previous_steps': previous_steps, + 'previous_step_counter': previous_step_counter}) storage = self.storage # if modification: show the next steps if self.modification: @@ -166,23 +168,24 @@ class Wizard(NamedUrlWizardView): elif current_step_passed: next_steps.append(self.form_list[next_step]) next_step = self.get_next_step(next_step) - context.update({'next_steps':next_steps}) + context.update({'next_steps': next_steps}) # not last step: validation if current_step != self.steps.last: return context final_form_list = [] for form_key in self.get_form_list().keys(): - form_obj = self.get_form(step=form_key, - data=self.storage.get_step_data(form_key), - files=self.storage.get_step_files(form_key)) + form_obj = self.get_form( + step=form_key, + data=self.storage.get_step_data(form_key), + files=self.storage.get_step_files(form_key)) form_obj.is_valid() final_form_list.append(form_obj) last_form = final_form_list[-1] - context.update({'datas':self.get_formated_datas(final_form_list)}) + context.update({'datas': self.get_formated_datas(final_form_list)}) if hasattr(last_form, 'confirm_msg'): - context.update({'confirm_msg':last_form.confirm_msg}) + context.update({'confirm_msg': last_form.confirm_msg}) if hasattr(last_form, 'confirm_end_msg'): - context.update({'confirm_end_msg':last_form.confirm_end_msg}) + context.update({'confirm_end_msg': last_form.confirm_end_msg}) return context def get_formated_datas(self, forms): @@ -191,18 +194,17 @@ class Wizard(NamedUrlWizardView): for form in forms: base_form = hasattr(form, 'forms') and form.forms[0] or form associated_models = hasattr(base_form, 'associated_models') and \ - base_form.associated_models or {} + base_form.associated_models or {} if not hasattr(form, 'cleaned_data') and hasattr(form, 'forms'): cleaned_datas = [frm.cleaned_data for frm in form.forms - if frm.is_valid()] + if frm.is_valid()] if not cleaned_datas: continue elif not hasattr(form, 'cleaned_data'): continue else: cleaned_datas = type(form.cleaned_data) == list and \ - form.cleaned_data \ - or [form.cleaned_data] + form.cleaned_data or [form.cleaned_data] if hasattr(base_form, 'get_formated_datas'): datas.append((form.form_label, base_form.get_formated_datas(cleaned_datas))) @@ -653,9 +655,7 @@ class Wizard(NamedUrlWizardView): def session_get_value(self, form_key, key, multi=False): """Get the value of a specific form""" - print(form_key, key, multi) if not self.session_has_key(form_key, key, multi): - print('OUT!') return request = self.request storage = self.storage |