summaryrefslogtreecommitdiff
path: root/archaeological_context_records/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2012-10-21 15:04:28 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2012-10-21 15:04:28 +0200
commit038b12ea13407d69fbbe8f0fae3067aa55f1f763 (patch)
treea8d881b59447269f2e92578cf5924759bad17704 /archaeological_context_records/wizards.py
parentea73bf44c5d527f407c89b35b22b21abf2f32617 (diff)
downloadIshtar-038b12ea13407d69fbbe8f0fae3067aa55f1f763.tar.bz2
Ishtar-038b12ea13407d69fbbe8f0fae3067aa55f1f763.zip
Djangoization - Major refactoring (step 8)
* clean-up on request and storage args in methods * view creation now managed by South * clean some mess in session values by using MultiValueDict
Diffstat (limited to 'archaeological_context_records/wizards.py')
-rw-r--r--archaeological_context_records/wizards.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py
index 1fd657bcc..86ce3bd30 100644
--- a/archaeological_context_records/wizards.py
+++ b/archaeological_context_records/wizards.py
@@ -30,30 +30,29 @@ class RecordWizard(Wizard):
model = models.ContextRecord
edit = False
- def get_current_operation(self, request, storage):
- step = storage.get_current_step()
+ def get_current_operation(self):
+ step = self.steps.current
if not step:
return
if step.endswith('_creation'): # an operation has been selected
main_form_key = 'selec-' + self.url_name
try:
- idx = int(self.session_get_value(request, storage,
- main_form_key, 'operation_id'))
+ idx = int(self.session_get_value(main_form_key, 'operation_id'))
current_ope = models.Operation.objects.get(pk=idx)
return current_ope
except(TypeError, ValueError, ObjectDoesNotExist):
pass
- current_cr = self.get_current_object(request, storage)
+ current_cr = self.get_current_object()
if current_cr:
return current_cr.parcel.operation
- def get_template_context(self, request, storage, form=None):
+ # get_template_context
+ def get_context_data(self, form, **kwargs):
"""
Get the operation "reminder" on top of wizard forms
"""
- context = super(RecordWizard, self).get_template_context(request,
- storage, form)
- operation = self.get_current_operation(request, storage)
+ context = super(RecordWizard, self).get_context_data(form)
+ operation = self.get_current_operation()
if not operation:
return context
items = []
@@ -64,7 +63,7 @@ class RecordWizard(Wizard):
context['reminder'] = _("Current operation: ") + " - ".join(items)
return context
- def get_form(self, request, storage, step=None, data=None, files=None):
+ def get_form(self, step=None, data=None, files=None):
"""
Get associated operation
"""
@@ -75,24 +74,23 @@ class RecordWizard(Wizard):
if not step:
step = self.steps.current
#step = self.determine_step(request, storage)
- form = self.get_form_list(request, storage)[step]
+ form = self.get_form_list()[step]
general_form_key = 'general-' + self.url_name
if step.startswith('general-'):
if step.endswith('_creation'): # an operation has been selected
main_form_key = 'selec-' + self.url_name
try:
- idx = int(self.session_get_value(request, storage,
- main_form_key, 'operation_id'))
+ idx = int(self.session_get_value(main_form_key,
+ 'operation_id'))
current_obj = models.Operation.objects.get(pk=idx)
data['operation'] = current_obj
except(TypeError, ValueError, ObjectDoesNotExist):
pass
else:
- current_object = self.get_current_object(request, storage)
+ current_object = self.get_current_object()
data['context_record'] = current_object
- form = super(RecordWizard, self).get_form(request, storage, step, data,
- files)
+ form = super(RecordWizard, self).get_form(step, data, files)
return form
class RecordModifWizard(RecordWizard):