diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-07-10 21:51:54 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-07-10 21:51:54 +0200 |
commit | efdc0e0fd8c8d128b75b6ea8516d2ba79545413f (patch) | |
tree | 35397441d3a8e259aacbe11f52e35ca87bc5a7cb | |
parent | a500dd90aca319d9306cf08c7c5ad73d4e27a261 (diff) | |
download | Ishtar-efdc0e0fd8c8d128b75b6ea8516d2ba79545413f.tar.bz2 Ishtar-efdc0e0fd8c8d128b75b6ea8516d2ba79545413f.zip |
Parcels: display a warning when automatically adding parcel to a file from an operation
-rw-r--r-- | archaeological_operations/wizards.py | 13 | ||||
-rw-r--r-- | ishtar_common/static/media/style.css | 4 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/wizard/parcels_wizard.html | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 081281d8a..707f4f96f 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -85,6 +85,10 @@ class OperationWizard(Wizard): elif step.startswith('parcels-') and self.get_current_file(): # if a file is acciated to the operation add the button "Add all" context['add_all'] = True + if step.startswith('parcels') and\ + hasattr(self, 'automatic_parcel_association'): + context['automatic_parcel_association'] = \ + self.automatic_parcel_association # reminder of the current file reminder = self.get_reminder() if reminder: @@ -108,6 +112,7 @@ class OperationWizard(Wizard): return sorted(towns, key=lambda x:x[1]) def get_available_parcels(self, file): + self.automatic_parcel_association = False parcels = [] current_parcels = [] operation = self.get_current_object() @@ -118,10 +123,14 @@ class OperationWizard(Wizard): parcels.append((parcel.pk, parcel.short_label)) try: for parcel in file.parcels.all(): - if (parcel.town, parcel.section, parcel.parcel_number) \ - in current_parcels: + key = (parcel.town, parcel.section, parcel.parcel_number) + if key in current_parcels: + current_parcels.pop(current_parcels.index(key)) continue parcels.append((parcel.pk, parcel.short_label)) + if current_parcels: + # not all operation parcel exist for the file + self.automatic_parcel_association = True except (ValueError, ObjectDoesNotExist): pass return sorted(parcels, key=lambda x:x[1]) diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 5168cba6e..cad7d296d 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -819,6 +819,10 @@ p.alert{ background-position:left center; } +div.form p.alert{ + background-color:#FFF; +} + #window p.alert{ background-color:#EEE; } diff --git a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html index b550cf6c4..3a5cba007 100644 --- a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html @@ -10,6 +10,7 @@ {{ wizard.management_form }} {{ wizard.form.management_form }} <div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div> +{% if automatic_parcel_association %}<p class='alert'><label>{%trans "Existing parcels from the operation will be automatically added to the archaeological file." %}</label></p>{% endif %} {%if wizard.form.non_form_errors%} <table class='formset'> <tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr> |