summaryrefslogtreecommitdiff
path: root/archaeological_operations/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 21:32:30 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 21:32:30 +0100
commitd71150129e1189f57d146b31b1042d43ea66083f (patch)
treeaf6cbbeb81036c1e20a188359cffd5d9b63debaf /archaeological_operations/wizards.py
parent08e1df4d3a049ed300fa87712fc60a0ec96b26cf (diff)
downloadIshtar-d71150129e1189f57d146b31b1042d43ea66083f.tar.bz2
Ishtar-d71150129e1189f57d146b31b1042d43ea66083f.zip
Display a reminder of items concerned by the current edition (refs #1218)
Diffstat (limited to 'archaeological_operations/wizards.py')
-rw-r--r--archaeological_operations/wizards.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index f20999f18..07c8844b9 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -45,6 +45,19 @@ class OperationWizard(Wizard):
templates = ['ishtar/wizard/parcels_wizard.html'] + templates
return templates
+ def get_current_file(self):
+ step = self.steps.current
+ if not step:
+ return
+ main_form_key = 'general-' + self.url_name
+ try:
+ idx = int(self.session_get_value(main_form_key,
+ 'associated_file'))
+ current_file = models.File.objects.get(pk=idx)
+ return current_file
+ except(TypeError, ValueError, ObjectDoesNotExist):
+ pass
+
def get_context_data(self, form, **kwargs):
"""
Return extra context for templates
@@ -54,13 +67,15 @@ class OperationWizard(Wizard):
step = self.steps.current
if step.startswith('towns-'):
context['TOWNS'] = self.get_towns()
- elif step.startswith('parcels-'):
+ elif step.startswith('parcels-') and self.get_current_file():
# if a file is acciated to the operation add the button "Add all"
- general_form_key = 'general-' + self.url_name
- file_id = self.session_get_value(general_form_key,
- "associated_file")
- if file_id:
- context['add_all'] = True
+ context['add_all'] = True
+ # reminder of the current file
+ archaeological_file = self.get_current_file()
+ if not archaeological_file or self.steps.current.startswith('general-'):
+ return context
+ context['reminders'] = ((_("Archaelogical file"),
+ unicode(archaeological_file)),)
return context
def get_towns(self):