diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-08-18 15:07:58 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-08-18 15:07:58 +0200 |
commit | 601bcd199a5078ad951f3bce77edc0f1f940a790 (patch) | |
tree | cd116e3bfaab2167f5f63ddc350eb55b678acf23 /ishtar_common/wizards.py | |
parent | b158c7375e7cf025b9a3f11cc6978b8a6c6f45b6 (diff) | |
download | Ishtar-601bcd199a5078ad951f3bce77edc0f1f940a790.tar.bz2 Ishtar-601bcd199a5078ad951f3bce77edc0f1f940a790.zip |
Archaeological files: associate many towns. PEP8 and formating.
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index e30d33711..c01ef5301 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +22,7 @@ import datetime from django.conf import settings from django.contrib.formtools.wizard.storage import get_storage from django.contrib.formtools.wizard.views import NamedUrlWizardView, \ - normalize_name + normalize_name from django.core.exceptions import ObjectDoesNotExist from django.core.files.images import ImageFile from django.db.models.fields.files import FileField @@ -34,6 +34,7 @@ from django.utils.datastructures import MultiValueDict as BaseMultiValueDict from django.utils.translation import ugettext_lazy as _ import models + class MultiValueDict(BaseMultiValueDict): def get(self, *args, **kwargs): v = super(MultiValueDict, self).getlist(*args, **kwargs) @@ -45,6 +46,7 @@ class MultiValueDict(BaseMultiValueDict): v = super(MultiValueDict, self).get(*args, **kwargs) return v + class Wizard(NamedUrlWizardView): model = None label = '' @@ -614,13 +616,18 @@ class Wizard(NamedUrlWizardView): request = self.request storage = self.storage test = storage.prefix in request.session \ - and 'step_data' in request.session[storage.prefix] \ - and form_key in request.session[storage.prefix]['step_data'] + and 'step_data' in request.session[storage.prefix] \ + and form_key in request.session[storage.prefix]['step_data'] if not key or not test: return test + if multi: + # only check if the first field is available + key = key.startswith(form_key) and key or \ + form_key + '-0-' + key + if key in request.session[storage.prefix]['step_data'][form_key]: + return True key = key.startswith(form_key) and key or \ - not multi and form_key + '-' + key or \ - form_key + '-0-' + key #only check if the first field is available + form_key + '-' + key return key in request.session[storage.prefix]['step_data'][form_key] @classmethod @@ -646,7 +653,9 @@ 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 @@ -786,6 +795,7 @@ class Wizard(NamedUrlWizardView): initial.append(vals) return initial + class SearchWizard(NamedUrlWizardView): model = None label = '' @@ -816,6 +826,7 @@ class SearchWizard(NamedUrlWizardView): 'wizard_label':self.label}) return context + class DeletionWizard(Wizard): def __init__(self, *args, **kwargs): if (not hasattr(self, 'fields') or not self.fields) and \ @@ -865,6 +876,7 @@ class DeletionWizard(Wizard): return render_to_response('ishtar/wizard/wizard_delete_done.html', {}, context_instance=RequestContext(self.request)) + class ClosingWizard(Wizard): # "close" an item # to be define in the overloaded class @@ -915,24 +927,30 @@ class ClosingWizard(Wizard): return render_to_response('ishtar/wizard/wizard_closing_done.html', {}, context_instance=RequestContext(self.request)) + class PersonWizard(Wizard): model = models.Person + class PersonModifWizard(PersonWizard): modification = True + class PersonDeletionWizard(DeletionWizard): model = models.Person fields = model.TABLE_COLS wizard_templates = { 'final-person_deletion':'ishtar/wizard/wizard_person_deletion.html'} + class OrganizationWizard(Wizard): model = models.Organization + class OrganizationModifWizard(OrganizationWizard): modification = True + class OrganizationDeletionWizard(DeletionWizard): model = models.Organization fields = model.TABLE_COLS @@ -940,6 +958,7 @@ class OrganizationDeletionWizard(DeletionWizard): 'final-organization_deletion':\ 'ishtar/wizard/wizard_organization_deletion.html'} + class AccountWizard(Wizard): model = models.Person def get_formated_datas(self, forms): @@ -1023,6 +1042,7 @@ class AccountWizard(Wizard): form.is_hidden = False return form + class SourceWizard(Wizard): model = None def get_extra_model(self, dct, form_list): |