summaryrefslogtreecommitdiff
path: root/archaeological_finds/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_finds/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_finds/wizards.py')
-rw-r--r--archaeological_finds/wizards.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index 2352863eb..4d2a54f73 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -26,35 +26,34 @@ from django.utils.translation import ugettext_lazy as _
from ishtar_common.wizards import Wizard, DeletionWizard, SourceWizard
import models
-class ItemWizard(Wizard):
- model = models.Item
+class FindWizard(Wizard):
+ model = models.Find
- def get_current_contextrecord(self, request, storage):
- step = storage.get_current_step()
+ def get_current_contextrecord(self):
+ step = self.steps.current
if not step:
return
if step.endswith('_creation'): # a context record has been selected
main_form_key = 'selecrecord-' + self.url_name
try:
- idx = int(self.session_get_value(request, storage,
- main_form_key, 'pk'))
+ idx = int(self.session_get_value(main_form_key, 'pk'))
current_cr = models.ContextRecord.objects.get(pk=idx)
return current_cr
except(TypeError, ValueError, ObjectDoesNotExist):
pass
- current_item = self.get_current_object(request, storage)
+ current_item = self.get_current_object()
if current_item:
base_finds = current_item.base_finds.all()
if base_finds:
return base_finds[0].context_record
- def get_template_context(self, request, storage, form=None):
+ #def get_template_context(self, request, storage, form=None):
+ def get_context_data(self, form, **kwargs):
"""
Get the operation and context record "reminder" on top of wizard forms
"""
- context = super(ItemWizard, self).get_template_context(request,
- storage, form)
- current_cr = self.get_current_contextrecord(request, storage)
+ context = super(FindWizard, self).get_context_data(form, **kwargs)
+ current_cr = self.get_current_contextrecord()
if not current_cr:
return context
operation = current_cr.operation
@@ -69,25 +68,24 @@ class ItemWizard(Wizard):
context['reminder'] = mark_safe(reminder)
return context
- def get_extra_model(self, dct, request, storage, form_list):
- dct = super(ItemWizard, self).get_extra_model(dct, request, storage,
- form_list)
+ def get_extra_model(self, dct, form_list):
+ dct = super(FindWizard, self).get_extra_model(dct, form_list)
dct['order'] = 1
if 'pk' in dct and type(dct['pk']) == models.ContextRecord:
dct['base_finds__context_record'] = dct.pop('pk')
return dct
-class ItemModificationWizard(ItemWizard):
+class FindModificationWizard(FindWizard):
modification = True
class TreatmentWizard(Wizard):
model = models.Treatment
-class ItemSourceWizard(SourceWizard):
- model = models.ItemSource
+class FindSourceWizard(SourceWizard):
+ model = models.FindSource
-class ItemSourceDeletionWizard(DeletionWizard):
- model = models.ItemSource
+class FindSourceDeletionWizard(DeletionWizard):
+ model = models.FindSource
fields = ['item', 'title', 'source_type', 'authors',]
class TreatmentSourceWizard(SourceWizard):