diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-10-13 01:22:50 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2014-10-13 01:22:50 +0200 |
commit | fc4248a63aef13c8c7144a412bf52640432eed72 (patch) | |
tree | 0f6825eee3d3a9e1c9b809929b1e216cd7425b61 | |
parent | add5a8d76c65530806c35d11b723c8f6be350b5f (diff) | |
download | Ishtar-fc4248a63aef13c8c7144a412bf52640432eed72.tar.bz2 Ishtar-fc4248a63aef13c8c7144a412bf52640432eed72.zip |
Add reminders for administrativ acts (refs #2060)
-rw-r--r-- | archaeological_files/wizards.py | 24 | ||||
-rw-r--r-- | archaeological_operations/wizards.py | 35 |
2 files changed, 53 insertions, 6 deletions
diff --git a/archaeological_files/wizards.py b/archaeological_files/wizards.py index 7fb654b0b..4ad947641 100644 --- a/archaeological_files/wizards.py +++ b/archaeological_files/wizards.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2012-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2012-2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -155,6 +155,28 @@ class FileDeletionWizard(FileClosingWizard): class FileAdministrativeActWizard(OperationAdministrativeActWizard): model = models.File + def get_reminder(self): + form_key = 'selec-' + self.url_name + if self.url_name.endswith('_administrativeactfile'): + # modification and deletion are suffixed with '_modification' + # and '_deletion' so it is creation + file_id = self.session_get_value(form_key, "pk") + try: + return ((_(u"Archaelogical file"), + unicode(models.File.objects.get(pk=file_id))),) + except models.File.DoesNotExist: + return + else: + admin_id = self.session_get_value(form_key, "pk") + try: + admin = AdministrativeAct.objects.get(pk=admin_id) + if not admin.associated_file: + return + return ((_(u"Archaelogical file"), + unicode(admin.associated_file)),) + except AdministrativeAct.DoesNotExist: + return + class FileEditAdministrativeActWizard(FileAdministrativeActWizard): model = AdministrativeAct edit = True diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 70583068b..7d349b8b7 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -67,6 +67,12 @@ class OperationWizard(Wizard): except(TypeError, ValueError, ObjectDoesNotExist): pass + def get_reminder(self): + archaeological_file = self.get_current_file() + if archaeological_file: + return ((_("Archaelogical file"), + unicode(archaeological_file)),) + def get_context_data(self, form, **kwargs): """ Return extra context for templates @@ -80,11 +86,9 @@ class OperationWizard(Wizard): # if a file is acciated to the operation add the button "Add all" context['add_all'] = True # reminder of the current file - archaeological_file = self.get_current_file() - if not archaeological_file: - return context - context['reminders'] = ((_("Archaelogical file"), - unicode(archaeological_file)),) + reminder = self.get_reminder() + if reminder: + context['reminders'] = reminder return context def get_towns(self): @@ -277,6 +281,27 @@ class OperationSourceDeletionWizard(DeletionWizard): class OperationAdministrativeActWizard(OperationWizard): edit = False + def get_reminder(self): + form_key = 'selec-' + self.url_name + if self.url_name.endswith('_administrativeactop'): + # modification and deletion are suffixed with '_modification' + # and '_deletion' so it is creation + operation_id = self.session_get_value(form_key, "pk") + try: + return ((_(u"Operation"), + unicode(models.Operation.objects.get(pk=operation_id))),) + except models.Operation.DoesNotExist: + return + else: + admin_id = self.session_get_value(form_key, "pk") + try: + admin = models.AdministrativeAct.objects.get(pk=admin_id) + if not admin.operation: + return + return ((_(u"Operation"), unicode(admin.operation)),) + except models.AdministrativeAct.DoesNotExist: + return + def get_extra_model(self, dct, form_list): dct['history_modifier'] = self.request.user return dct |