summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-12-07 21:10:37 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-12-07 21:10:37 +0100
commit039c52d726f73fc04fc974ba8ff18511d275fb66 (patch)
tree593c74181491d8fbe339b6148d72de2148a67b89
parent1eb19b3028430a4f936193304d70ef5ce429492e (diff)
downloadIshtar-039c52d726f73fc04fc974ba8ff18511d275fb66.tar.bz2
Ishtar-039c52d726f73fc04fc974ba8ff18511d275fb66.zip
Archaeological files: better check for numeric_reference
-rw-r--r--archaeological_files_pdl/templates/ishtar/wizard/file_confirm_wizard.html11
-rw-r--r--archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html4
-rw-r--r--archaeological_files_pdl/wizards.py48
3 files changed, 45 insertions, 18 deletions
diff --git a/archaeological_files_pdl/templates/ishtar/wizard/file_confirm_wizard.html b/archaeological_files_pdl/templates/ishtar/wizard/file_confirm_wizard.html
index 45298c896..18b8378de 100644
--- a/archaeological_files_pdl/templates/ishtar/wizard/file_confirm_wizard.html
+++ b/archaeological_files_pdl/templates/ishtar/wizard/file_confirm_wizard.html
@@ -3,6 +3,17 @@
{% load i18n %}
{% block "warning_informations" %}
+{% for file in numeric_reference_files %}
+{% if forloop.first %}
+<p class='alert'><label>{% trans "These(s) file(s) have the same numeric index." %}</label></p>
+<ul>
+{% endif%}
+ <li>{{file}} <a href='#' onclick='load_window("{% url 'show-file' file.pk '' %}", "{{model_name}}");' class='display_details'>{% trans "Details" %}</a></li>
+{% if forloop.last %}
+</ul>
+<hr/>
+{% endif %}
+{% endfor %}
{% for file in similar_files %}
{% if forloop.first %}
<p class='alert'><label>{% trans "These(s) file(s) are in the same town and have parcel(s) in common." %}</label></p>
diff --git a/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html b/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html
index 120b6f9ab..841b64847 100644
--- a/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html
+++ b/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html
@@ -5,7 +5,7 @@
<div class='form'>
{{ wizard.form.media }}
{{ wizard.management_form }}
-
+{{wizard.form.errors}}
<table>
<tr class='required'>
@@ -36,7 +36,7 @@
<td><input type='radio' name='state' value='open' id='state-open'/> <label for='state-open'>Dossier actif</label></td>
</tr>
<tr>
- <td><input type='radio' name='state' value='closed' id='state-closed'/> <label for='state-closed'>Dossier clos / date de clôture</label> : {{wizard.form.end_date|safe}}</td>
+ <td>{{wizard.form.end_date.errors}}<input type='radio' name='state' value='closed' id='state-closed'/> <label for='state-closed'>Dossier clos / date de clôture</label> : {{wizard.form.end_date|safe}}</td>
</tr>
<tr class='required'>
diff --git a/archaeological_files_pdl/wizards.py b/archaeological_files_pdl/wizards.py
index 61294e538..c64c70eab 100644
--- a/archaeological_files_pdl/wizards.py
+++ b/archaeological_files_pdl/wizards.py
@@ -85,24 +85,40 @@ class FileWizard(BaseFileWizard):
if saisine_type:
context['saisine_type'] = unicode(saisine_type)
context['saisine_type_delay'] = saisine_type.delay or 0
- elif self.steps.current == formfinal and \
- self.steps.current.endswith('creation'): # creation only
- parcels = []
- parcel_step_key = self.parcel_step_key + self.url_name
-
- parcel_numbers = self.session_get_value(
- parcel_step_key, 'parcel_number', multi=True) or []
- sections = self.session_get_value(
- parcel_step_key, 'section', multi=True) or []
- towns = self.session_get_value(
- parcel_step_key, 'town', multi=True) or []
- for idx, parcel_number in enumerate(parcel_numbers):
- if not parcel_number:
- continue
- parcels.append({'town': towns[idx],
+ elif self.steps.current == formfinal:
+ if self.steps.current.endswith('creation'): # creation only
+ parcels = []
+ parcel_step_key = self.parcel_step_key + self.url_name
+
+ parcel_numbers = self.session_get_value(
+ parcel_step_key, 'parcel_number', multi=True) or []
+ sections = self.session_get_value(
+ parcel_step_key, 'section', multi=True) or []
+ towns = self.session_get_value(
+ parcel_step_key, 'town', multi=True) or []
+ for idx, parcel_number in enumerate(parcel_numbers):
+ if not parcel_number:
+ continue
+ parcels.append({
+ 'town': towns[idx],
'section': sections[idx],
'parcel_number': parcel_number})
- context['similar_files'] = models.File.similar_files(parcels)
+ context['similar_files'] = models.File.similar_files(parcels)
+ else: # edition only
+ try:
+ numeric_reference = int(
+ self.session_get_value(
+ 'instruction-' + self.url_name,
+ 'numeric_reference'))
+
+ q = models.File.objects.filter(
+ numeric_reference=numeric_reference,
+ year=self.get_current_year()).exclude(
+ pk=self.get_current_object().pk)
+ context['numeric_reference_files'] = q.all()
+ except ValueError:
+ pass
+
return context