summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2012-10-21 22:49:56 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2012-10-21 22:49:56 +0200
commit39e0c9cf302f8b468e116047eef18f42d712166e (patch)
tree38ca8553def343f8aede7af10253286476c7eb24 /ishtar_common/wizards.py
parent4e2c3dcd9dc31221a467a5bb4e727fd06336ea07 (diff)
downloadIshtar-39e0c9cf302f8b468e116047eef18f42d712166e.tar.bz2
Ishtar-39e0c9cf302f8b468e116047eef18f42d712166e.zip
Djangoization - Major refactoring (step 14)
* Fix formset UI. * Fix formset towns. * Clean-up
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r--ishtar_common/wizards.py20
1 files changed, 0 insertions, 20 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 373ee0e41..8b6e1a50d 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -66,7 +66,6 @@ class Wizard(NamedUrlWizardView):
def __init__(self, *args, **kwargs):
"""Check right for each step of the wizard"""
- print "2"
super(Wizard, self).__init__(*args, **kwargs)
for form_key in self.form_list.keys()[:-1]:
condition = True
@@ -85,17 +84,14 @@ class Wizard(NamedUrlWizardView):
def get_prefix(self, *args, **kwargs):
"""As the class name can interfere when reused prefix with the url_name
"""
- print "3"
return self.url_name + super(Wizard, self).get_prefix(*args,
**kwargs)
def get_wizard_name(self):
"""As the class name can interfere when reused, use the url_name"""
- print "4"
return self.url_name
def get_template_names(self):
- print "5"
templates = ['ishtar/wizard/default_wizard.html']
current_step = self.steps.current
if current_step == self.steps.last:
@@ -104,7 +100,6 @@ class Wizard(NamedUrlWizardView):
def get_context_data(self, form, **kwargs):
"""Add previous, next and current steps to manage the wizard path"""
- print "6"
context = super(Wizard, self).get_context_data(form)
self.request.session['CURRENT_ACTION'] = self.get_wizard_name()
step = self.steps.first
@@ -170,7 +165,6 @@ class Wizard(NamedUrlWizardView):
def get_formated_datas(self, forms):
"""Get the data to present in the last page"""
- print "7"
datas = []
for form in forms:
form_datas = []
@@ -235,13 +229,11 @@ class Wizard(NamedUrlWizardView):
return datas
def get_extra_model(self, dct, form_list):
- print "8"
dct['history_modifier'] = self.request.user
return dct
def done(self, form_list, return_object=False, **kwargs):
"""Save to the model"""
- print "9"
dct, m2m, whole_associated_models = {}, [], []
for form in form_list:
if not form.is_valid():
@@ -311,17 +303,14 @@ class Wizard(NamedUrlWizardView):
def get_saved_model(self):
"""Permit a distinguo when saved model is not the base selected model"""
- print "10"
return self.model
def get_current_saved_object(self):
"""Permit a distinguo when saved model is not the base selected model"""
- print "11"
return self.get_current_object()
def save_model(self, dct, m2m, whole_associated_models, form_list,
return_object):
- print "12"
dct = self.get_extra_model(dct, form_list)
obj = self.get_current_saved_object()
# manage dependant items
@@ -423,7 +412,6 @@ class Wizard(NamedUrlWizardView):
def get_deleted(self, keys):
"""Get the deleted and non-deleted items in formsets"""
- print "13"
not_to_delete, to_delete = set(), set()
for key in keys:
items = key.split('-')
@@ -444,7 +432,6 @@ class Wizard(NamedUrlWizardView):
def get_form(self, step=None, data=None, files=None):
"""Manage formset"""
- print "14"
request = self.request
storage = self.storage
if data:
@@ -493,7 +480,6 @@ class Wizard(NamedUrlWizardView):
- modify or delete button in formset: next step = current step
- validate and end: nextstep = last step
"""
- print "15"
request = self.request
if request.POST.has_key('formset_modify') \
and request.POST['formset_modify'] \
@@ -512,7 +498,6 @@ class Wizard(NamedUrlWizardView):
def post(self, *args, **kwargs):
"""Convert numerical step number to step name"""
- print "16"
request = self.request
post_data = request.POST.copy()
if request.POST.has_key('form_prev_step'):
@@ -529,7 +514,6 @@ class Wizard(NamedUrlWizardView):
"""Check if the session has value of a specific form and (if provided)
of a key
"""
- print "17"
request = self.request
storage = self.storage
test = storage.prefix in request.session \
@@ -544,7 +528,6 @@ class Wizard(NamedUrlWizardView):
def session_get_value(self, form_key, key, multi=False):
"""Get the value of a specific form"""
- print "18"
if not self.session_has_key(form_key, key, multi):
return
request = self.request
@@ -568,7 +551,6 @@ class Wizard(NamedUrlWizardView):
def get_current_object(self):
"""Get the current object for an instancied wizard"""
- print "19"
current_obj = None
main_form_key = 'selec-' + self.url_name
try:
@@ -580,7 +562,6 @@ class Wizard(NamedUrlWizardView):
return current_obj
def get_form_initial(self, step):
- print "20"
current_obj = self.get_current_object()
current_step = self.steps.current
request = self.request
@@ -611,7 +592,6 @@ class Wizard(NamedUrlWizardView):
def get_instanced_init(self, obj, step=None):
"""Get initial data from an init"""
- print "21"
current_step = step or self.steps.current
c_form = self.form_list[current_step]
# make the current object the default item for the session