diff options
Diffstat (limited to 'archaeological_operations/wizards.py')
-rw-r--r-- | archaeological_operations/wizards.py | 27 |
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): |