summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2011-07-10 18:36:48 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2011-07-10 18:36:48 +0200
commit7dc79581218a205fb5b80ea6db306b77b9bd529b (patch)
treebe8d4564e68a0bf65a2b4f0136621d67f2acf62a
parent571aa094f71d152df9a8ce60cd41a0bcad64bd0b (diff)
downloadIshtar-7dc79581218a205fb5b80ea6db306b77b9bd529b.tar.bz2
Ishtar-7dc79581218a205fb5b80ea6db306b77b9bd529b.zip
Disambiguation of closing date and end of excavation work (closes #526)
-rw-r--r--ishtar/ishtar_base/admin.py3
-rw-r--r--ishtar/ishtar_base/forms_operations.py18
-rw-r--r--ishtar/ishtar_base/models.py2
-rw-r--r--ishtar/templates/sheet_file.html4
-rw-r--r--ishtar/templates/sheet_operation.html8
5 files changed, 27 insertions, 8 deletions
diff --git a/ishtar/ishtar_base/admin.py b/ishtar/ishtar_base/admin.py
index ace959295..e2388a86a 100644
--- a/ishtar/ishtar_base/admin.py
+++ b/ishtar/ishtar_base/admin.py
@@ -69,7 +69,8 @@ class FileAdmin(HistorizedObjectAdmin):
admin.site.register(models.File, FileAdmin)
class OperationAdmin(HistorizedObjectAdmin):
- list_display = ['year', 'operation_code', 'start_date', 'end_date',
+ list_display = ['year', 'operation_code', 'start_date',
+ 'excavation_end_date', 'end_date',
'operation_type']
list_filter = ("year", "operation_type",)
search_fields = ['towns__name', 'operation_code']
diff --git a/ishtar/ishtar_base/forms_operations.py b/ishtar/ishtar_base/forms_operations.py
index 6e6cdc03e..5ed882530 100644
--- a/ishtar/ishtar_base/forms_operations.py
+++ b/ishtar/ishtar_base/forms_operations.py
@@ -232,6 +232,8 @@ class OperationFormGeneral(forms.Form):
choices=[])
start_date = forms.DateField(label=_(u"Start date"), required=False,
widget=widgets.JQueryDate)
+ excavation_end_date = forms.DateField(label=_(u"Excavation end date"),
+ required=False, widget=widgets.JQueryDate)
surface = forms.IntegerField(required=False, widget=widgets.AreaWidget,
label=_(u"Total surface (m²)"),
validators=[validators.MinValueValidator(0),
@@ -248,6 +250,20 @@ class OperationFormGeneral(forms.Form):
self.fields['operation_type'].choices = models.OperationType.get_types()
self.fields['operation_type'].help_text = models.OperationType.get_help()
+ def clean(self):
+ # verify the logic between start date and excavation end date
+ if not self.cleaned_data['excavation_end_date']:
+ return self.cleaned_data
+ if self.cleaned_data['excavation_end_date'] and \
+ not self.cleaned_data['start_date']:
+ raise forms.ValidationError(_(u"If you want to set an excavation \
+end date you have to provide a start date."))
+ if self.cleaned_data['excavation_end_date'] < \
+ self.cleaned_data['start_date']:
+ raise forms.ValidationError(_(u"The excavation end date cannot be \
+before the start date."))
+ return self.cleaned_data
+
class OperationFormReference(forms.Form):
form_label = _("References")
associated_models = {'in_charge':models.Person,
@@ -470,7 +486,7 @@ class OperationDateFormSelection(forms.Form):
class OperationClosingWizard(ClosingWizard):
model = models.Operation
fields = ['year', 'operation_code', 'operation_type', 'associated_file',
- 'in_charge', 'start_date', 'end_date', 'comment', 'towns', 'remains']
+'in_charge', 'start_date', 'excavation_end_date', 'comment', 'towns', 'remains']
class FinalOperationClosingForm(FinalForm):
confirm_msg = " "
diff --git a/ishtar/ishtar_base/models.py b/ishtar/ishtar_base/models.py
index 4c4cdfc2e..8c4c91dae 100644
--- a/ishtar/ishtar_base/models.py
+++ b/ishtar/ishtar_base/models.py
@@ -629,6 +629,8 @@ class Operation(BaseHistorizedItem, OwnPerms):
TABLE_COLS = ['operation_code', 'year', 'operation_type',
'remains', 'towns', 'associated_file', 'start_date']
start_date = models.DateField(_(u"Start date"), null=True, blank=True)
+ excavation_end_date = models.DateField(_(u"Excavation end date"), null=True,
+ blank=True)
end_date = models.DateField(_(u"Closing date"), null=True, blank=True)
in_charge = models.ForeignKey('Person', related_name='+', null=True,
blank=True, verbose_name=_(u"In charge"))
diff --git a/ishtar/templates/sheet_file.html b/ishtar/templates/sheet_file.html
index ea5842991..88ef1b3a2 100644
--- a/ishtar/templates/sheet_file.html
+++ b/ishtar/templates/sheet_file.html
@@ -91,7 +91,7 @@
<th>{% trans "Type" %}</th>
<th>{% trans "In charge" %}</th>
<th>{% trans "Start date" %}</th>
- <th>{% trans "End date" %}</th>
+ <th>{% trans "Excavation end date" %}</th>
<th class='link'>&nbsp;</th>
</tr>
{% for operation in item.operations.all %}
@@ -102,7 +102,7 @@
<td class='string'>{{operation.operation_type}}</td>
<td class='string'>{{operation.in_charge|default:""}}</td>
<td>{{operation.start_date|default:""}}</td>
- <td>{{operation.end_date|default:""}}</td>
+ <td>{{operation.excavation_end_date|default:""}}</td>
<td class='link'><a href="#" onclick='load_window("{%url show-operation operation.pk ''%}")'>{% trans "Details" %}</a></td>
</tr>
{% empty %}
diff --git a/ishtar/templates/sheet_operation.html b/ishtar/templates/sheet_operation.html
index 0005ca82c..aa571d20c 100644
--- a/ishtar/templates/sheet_operation.html
+++ b/ishtar/templates/sheet_operation.html
@@ -13,10 +13,10 @@
<p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history.all.0.history_date }}</span></p> <!-- date = now -->
-{% if item.start_date %}<p><label>{%trans "Begining date:"%}</label> <span class='value'>{{ item.start_date }}</span></p>{%endif%}
-{% if item.end_date %}<p><label>{%trans "Field work end date:"%}</label> <span class='value'>{{ item.end_date|default:"-" }}</span></p>{%endif%}
-
-<p><label>{%trans "Head scientist:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p>
+{% if item.start_date %}<p><label>{%trans "Begining date:"%}</label> <span class='value'>{{ item.start_date }}</span></p>
+<p><label>{%trans "Excavation end date:"%}</label> <span class='value'>{{ item.excavation_end_date|default:"-" }}</span></p>
+{%endif%}
+{% if item.in_charge %}<p><label>{%trans "Head scientist:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p>{%endif%}
<p><label>{%trans "State:"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p>
{% else %}{%trans "Closed operation"%}</span></p>
<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user }}</span></p>