From 549cd33d6390c7b5cd8043e4c63d0ceb0d1fcd05 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 8 Dec 2016 20:41:59 +0100 Subject: Manage file association for treatments --- archaeological_finds/forms.py | 17 +++++++++ archaeological_finds/models.py | 4 +- archaeological_finds/models_treatments.py | 8 ++-- .../templates/ishtar/sheet_treatment.html | 2 +- .../templates/ishtar/sheet_treatmentfile.html | 2 +- archaeological_finds/urls.py | 6 +++ archaeological_finds/views.py | 44 +++++++++++++++++++++- archaeological_finds/wizards.py | 7 ++++ 8 files changed, 79 insertions(+), 11 deletions(-) diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index fe717515e..541778d5c 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -784,6 +784,18 @@ class ModifyTreatmentForm(BaseTreatmentForm): return cleaned_data +class TreatmentFormFileChoice(forms.Form): + form_label = _(u"Associated file") + associated_models = {'file': models.TreatmentFile, } + currents = {'file': models.TreatmentFile} + file = forms.IntegerField( + label=_(u"Treatment file"), + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-treatmentfile'), + associated_model=models.TreatmentFile), + validators=[valid_id(models.TreatmentFile)], required=False) + + class TreatmentDeletionForm(FinalForm): confirm_msg = _( u"Are you sure you want to delete this treatment? All modification " @@ -885,6 +897,11 @@ class ModifyTreatmentFileForm(TreatmentFileForm): return cleaned_data +class TreatmentFileDeletionForm(FinalForm): + confirm_msg = _(u"Are you sure you want to delete this treatment file?") + confirm_end_msg = _(u"Would you like to delete this treatment file?") + + """ #################################### # Source management for treatments # diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 40251bba0..b64da70e3 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -1,6 +1,6 @@ from archaeological_finds.models_finds import MaterialType, ConservatoryState,\ PreservationType, IntegrityType, RemarkabilityType, ObjectType, BaseFind, \ - FindBasket, Find, FindSource, Property, IS_ISOLATED_CHOICES + FindBasket, Find, FindSource, Property, IS_ISOLATED_CHOICES, CHECK_CHOICES from archaeological_finds.models_treatments import TreatmentType, Treatment, \ AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \ FindTreatments, TreatmentSource, TreatmentFile, TreatmentFileType @@ -8,7 +8,7 @@ from archaeological_finds.models_treatments import TreatmentType, Treatment, \ __all__ = ['MaterialType', 'ConservatoryState', 'PreservationType', 'IntegrityType', 'RemarkabilityType', 'ObjectType', 'BaseFind', 'FindBasket', 'Find', 'FindSource', 'Property', - 'IS_ISOLATED_CHOICES', + 'IS_ISOLATED_CHOICES', 'CHECK_CHOICES', 'TreatmentType', 'Treatment', 'AbsFindTreatments', 'FindUpstreamTreatments', 'FindDownstreamTreatments', 'FindTreatments', 'TreatmentSource', 'TreatmentFile', diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index e6237efef..a826d2a4a 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -59,7 +59,7 @@ post_delete.connect(post_save_cache, sender=TreatmentType) class Treatment(BaseHistorizedItem, ImageModel, OwnPerms): SHOW_URL = 'show-treatment' - TABLE_COLS = ('year', 'index', 'treatment_types_lbl', 'label', 'person', + TABLE_COLS = ('year', 'index', 'treatment_types__label', 'label', 'person', 'start_date', 'downstream_cached_label', 'upstream_cached_label') REVERSED_BOOL_FIELDS = ['image__isnull'] @@ -208,10 +208,8 @@ class AbsFindTreatments(models.Model): # primary_key is set to prevent django to ask for an id column # treatment is not a primary key treatment_nb = models.IntegerField(_(u"Order")) - TABLE_COLS = ['treatment__treatment_type', - 'treatment__start_date', 'treatment__end_date', - 'treatment__location', 'treatment__container', - 'treatment__person', 'treatment_nb'] + TABLE_COLS = ["treatment__" + col for col in Treatment.TABLE_COLS] + \ + ['treatment_nb'] EXTRA_FULL_FIELDS_LABELS = { 'treatment__treatment_type': _(u"Treatment type"), 'treatment__start_date': _(u"Start date"), diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index 1dfe19844..f1bfd68d2 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -19,8 +19,8 @@