diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-11 17:46:46 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-11 17:46:46 +0100 |
commit | 52b513e0737f65e30b5e886f728a7fae16ace4c2 (patch) | |
tree | 5f60291fe22fc689f608ffc0ea8aeea9f7cd085f /archaeological_finds/wizards.py | |
parent | 38c111ec8b259158c152472ea96d070da2d39386 (diff) | |
download | Ishtar-52b513e0737f65e30b5e886f728a7fae16ace4c2.tar.bz2 Ishtar-52b513e0737f65e30b5e886f728a7fae16ace4c2.zip |
Administrative act for treatment and treatment files
Diffstat (limited to 'archaeological_finds/wizards.py')
-rw-r--r-- | archaeological_finds/wizards.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py index eb838eb66..f5f43f1e6 100644 --- a/archaeological_finds/wizards.py +++ b/archaeological_finds/wizards.py @@ -22,6 +22,9 @@ from django.utils.translation import ugettext_lazy as _ from ishtar_common.forms import reverse_lazy from ishtar_common.wizards import Wizard, DeletionWizard, SourceWizard +from archaeological_operations.wizards import OperationAdministrativeActWizard + +from archaeological_operations.models import AdministrativeAct import models @@ -129,6 +132,23 @@ class TreatmentDeletionWizard(DeletionWizard): 'goal', 'start_date', 'end_date', 'container'] +class TreatmentAdministrativeActWizard(OperationAdministrativeActWizard): + model = models.Treatment + current_obj_slug = 'administrativeacttreatment' + ref_object_key = 'treatment' + + def get_reminder(self): + return + + +class TreatmentEditAdministrativeActWizard(TreatmentAdministrativeActWizard): + model = AdministrativeAct + edit = True + + def get_associated_item(self, dct): + return self.get_current_object().treatment + + class TreatmentFileWizard(Wizard): model = models.TreatmentFile wizard_done_window = reverse_lazy('show-treatmentfile') @@ -145,6 +165,46 @@ class TreatmentFileDeletionWizard(DeletionWizard): 'creation_date', 'end_date', 'comment'] +class TreatmentFileAdministrativeActWizard( + OperationAdministrativeActWizard): + model = models.TreatmentFile + current_obj_slug = 'administrativeacttreatmentfile' + ref_object_key = 'treatment_file' + + 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 + pk = self.session_get_value(form_key, "pk") + try: + return ( + (_(u"Treatment file"), + unicode(models.Operation.objects.get(pk=pk))), + ) + except models.TreatmentFile.DoesNotExist: + return + else: + admin_id = self.session_get_value(form_key, "pk") + try: + admin = AdministrativeAct.objects.get(pk=admin_id) + if not admin.operation: + return + return ((_(u"Operation"), unicode(admin.operation)),) + except AdministrativeAct.DoesNotExist: + return + return + + +class TreatmentFileEditAdministrativeActWizard( + TreatmentFileAdministrativeActWizard): + model = AdministrativeAct + edit = True + + def get_associated_item(self, dct): + return self.get_current_object().treatment_file + + class FindSourceWizard(SourceWizard): wizard_done_window = reverse_lazy('show-findsource') model = models.FindSource |