summaryrefslogtreecommitdiff
path: root/archaeological_files
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2013-04-04 22:43:13 +0000
committerÉtienne Loks <etienne.loks@proxience.com>2013-04-04 22:43:13 +0000
commitee8c9ad6004ab35e409c7041a0eba214b45c36d7 (patch)
treea2c624b1ce76c6d57a8a156766e4863710d8ae19 /archaeological_files
parent56aea239caffef95c481aac3b77a8d43e8d3ca35 (diff)
parente51684c2adb656d3ef14e40e649e280a6c0bf1b8 (diff)
downloadIshtar-ee8c9ad6004ab35e409c7041a0eba214b45c36d7.tar.bz2
Ishtar-ee8c9ad6004ab35e409c7041a0eba214b45c36d7.zip
Merge branch 'master' of lysithea.proxience.net:/home/proxience/git/ishtar
Diffstat (limited to 'archaeological_files')
-rw-r--r--archaeological_files/forms.py17
-rw-r--r--archaeological_files/models.py6
-rw-r--r--archaeological_files/templates/ishtar/sheet_file.html154
-rw-r--r--archaeological_files/templates/ishtar/sheet_file_pdf.html18
-rw-r--r--archaeological_files/templates/ishtar/sheet_file_window.html3
-rw-r--r--archaeological_files/views.py8
-rw-r--r--archaeological_files/wizards.py8
7 files changed, 204 insertions, 10 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py
index 564d0c6fc..ea12c984c 100644
--- a/archaeological_files/forms.py
+++ b/archaeological_files/forms.py
@@ -36,13 +36,14 @@ from ishtar_common.models import Person, PersonType, Town, Organization, \
from archaeological_operations.models import ActType, AdministrativeAct
import models
from ishtar_common.forms import FinalForm, FormSet, ClosingDateFormSelection, \
- formset_factory, get_now, reverse_lazy
+ formset_factory, get_now, reverse_lazy, TableSelect
from ishtar_common.forms_common import get_town_field, get_person_field
from archaeological_operations.forms import AdministrativeActOpeForm, \
- AdministrativeActOpeFormSelection, FinalAdministrativeActDeleteForm
+ AdministrativeActOpeFormSelection, FinalAdministrativeActDeleteForm, \
+ ParcelField
from ishtar_common import widgets
-class FileSelect(forms.Form):
+class FileSelect(TableSelect):
towns = get_town_field()
in_charge = get_person_field(label=_(u"Person in charge"),
person_type='sra_agent')
@@ -50,12 +51,20 @@ class FileSelect(forms.Form):
choices=models.FileType.get_types())
saisine_type = forms.ChoiceField(label=_("Saisine type"), choices=[])
year = forms.IntegerField(label=_("Year"))
+ parcel = ParcelField(label=_("Parcel (section/number)"))
def __init__(self, *args, **kwargs):
super(FileSelect, self).__init__(*args, **kwargs)
self.fields['saisine_type'].choices = models.SaisineType.get_types()
self.fields['saisine_type'].help_text = models.SaisineType.get_help()
+ def get_input_ids(self):
+ ids = super(FileSelect, self).get_input_ids()
+ ids.pop(ids.index('parcel'))
+ ids.append('parcel_0')
+ ids.append('parcel_1')
+ return ids
+
class FileFormSelection(forms.Form):
form_label = _("Archaeological file search")
associated_models = {'pk':models.File}
@@ -170,7 +179,7 @@ class FinalFileDeleteForm(FinalForm):
confirm_msg = " "
confirm_end_msg = _(u"Would you like to delete this archaelogical file ?")
-class AdministrativeActFileSelect(forms.Form):
+class AdministrativeActFileSelect(TableSelect):
associated_file__towns = get_town_field()
act_type = forms.ChoiceField(label=_("Act type"), choices=[])
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index a91f6ed69..1e2c36ed0 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2012-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -133,6 +133,10 @@ class File(BaseHistorizedItem, OwnPerms):
for k in ['internal_reference',] if getattr(self, k)]
return settings.JOINT.join(items)
+ def grouped_parcels(self):
+ from archaeological_operations.models import Parcel
+ return Parcel.grouped_parcels(list(self.parcels.all()))
+
@classmethod
def get_query_owns(cls, user):
return Q(history_modifier=user) & Q(end_date__isnull=True)
diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html
new file mode 100644
index 000000000..bdf0bd4ff
--- /dev/null
+++ b/archaeological_files/templates/ishtar/sheet_file.html
@@ -0,0 +1,154 @@
+{% extends "ishtar/sheet.html" %}
+{% load i18n %}
+{% block content %}
+{% if previous or next %}
+<div class='tool'>
+{%if previous%}
+<a href="#" onclick='load_window("{% url show-historized-file item.pk previous|date:"c"%}");$("#{{window_id}}").hide();return false;'>{%trans "Previous version"%} ({{previous}})</a>
+{% endif %}
+{% if previous and next %} - {% endif %}
+{%if next%}
+<a href="#" onclick='if(confirm("{%trans "Are you sure to rollback to this version?"%}")){load_url("{% url revert-file item.pk item.history_date|date:"c"%}");closeAllWindows();load_window("{% url show-file item.pk None %}");}'>Rollback</a> -
+<a href="#" onclick='load_window("{% url show-historized-file item.pk next|date:"c" %}");$("#{{window_id}}").hide();return false;'>{%trans "Next version"%} ({{next}})</a>
+{% endif %}
+</div>
+{% endif %}
+<div class='tool'>{%trans "Export as:"%} <a href='{% url show-file item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-file item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
+<h3>{% trans "General"%}</h3>
+<p><label>{%trans "Year:"%}</label> <span class='value'>{{ item.year }}</span></p>
+<p><label>{%trans "Numerical reference:"%}</label> <span class='value'>{{ item.numeric_reference }}</span></p>
+
+<p><label>{%trans "File's name:"%}</label> <span class='value'>{{ item.internal_reference }}</span></p>
+
+<p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history_date }}</span></p> <!-- date = now -->
+{% if item.reception_date %}<p><label>{%trans "Reception date:"%}</label> <span class='value'>{{ item.reception_date }}</span></p>{% endif %}
+<p><label>{%trans "Creation date:"%}</label> <span class='value'>{{ item.creation_date }}</span></p>
+{% comment %}
+{% if item.deadline_date and not item.acts %}
+ <p><label>{%trans "Deadline:"%}</label> <span class='value'>{% item.deadline_date %}</span></p> <!-- calculated deadline for some preventive files , see saisine_type, not displayed if an act as been send -->
+{% endif %}
+{% endcomment %}
+
+<p><label>{%trans "In charge:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p>
+<p><label>{%trans "State:"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p>
+{% else %}{%trans "Closed file"%}</span></p>
+<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user }}</span></p>
+{% endif %}
+
+<p><label>{%trans "Type:"%}</label> <span class='value'>{{ item.file_type }}</span></p>
+
+{% if item.related_file %}<p><label>{%trans "Related file:"%}</label> <span class='value'><a href='#' onclick='load_window("{% url show-file item.related_file.pk ''%}")'>{{ item.related_file }}</a></span></p>{% endif %} <!-- Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related file -->
+{% if item.comment %}<p><label>{%trans "Comment:"%}</label> <span class='value'>{{ item.comment }}</span></p>{%endif%}
+
+<h3>{% trans "Localisation"%}</h3>
+<p><label>{%trans "Towns:"%}</label> <span class='value'>{{ item.towns.all|join:", " }}</span></p>
+
+<p><label>{%trans "Main address:"%}</label> <span class='value'>{{ item.address }}</span></p>
+{% if item.address_complement %}<p><label>{%trans "Complement:"%}</label> <span class='value'>{{ item.address_complement }}</span></p>{%endif%}
+{% if item.postal_code %}<p><label>{%trans "Postal code:"%}</label> <span class='value'>{{ item.postal_code }}</span></p>{%endif%}
+
+<p><label>{%trans "Surface:"%}</label>{% if item.total_surface %} <span class='value'>{{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha)</span>{%endif%}</p>
+
+
+
+{% if item.is_preventive %}
+<h3>{% trans "Preventive archaelogical file"%}</h3>
+<p><label>{%trans "Planed surface:"%}</label> <span class='value'>{{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></p>
+<p><label>{%trans "Saisine type:"%}</label> <span class='value'>{{ item.saisine_type }}</span></p>
+{% if item.town_planning_service %}<p><label>{%trans "Town planning service:"%}</label> <span class='value'>{{ item.town_planning_service }}</span></p>{% endif %}
+{% if item.permit_type %}<p><label>{%trans "Permit type:"%}</label> <span class='value'>{{ item.permit_type }}</span></p>{% endif %}
+{% if item.permit_reference %}<p><label>{%trans "Permit reference:"%}</label> <span class='value'>{{ item.permit_reference }}</span></p>{% endif %}
+{% if item.general_contractor.attached_to %}<p><label>{%trans "General contractor organisation:"%}</label> <span class='value'>{{ item.general_contractor.attached_to }}</span></p>{% endif %} <!-- Contractor's organisation displayed as concat of Name/Adress/postal_code/city -->
+{% if item.general_contractor %}<p><label>{%trans "General contractor:"%}</label> <span class='value'>{{ item.general_contractor.full_label }}</span></p>{% endif %}
+{% endif %}
+
+<table>
+ <caption>{%trans "Associated parcels"%}</caption>
+ <tr>
+ <th>{% trans "Commune" %}</th>
+ <th>{% trans "Year" %}</th>
+ <th>{% trans "Section" %}</th>
+ <th>{% trans "Parcels" %}</th>
+ {#<th>{% trans "Owner" %}</th>#}
+ </tr>
+ {% for parcel in item.grouped_parcels %}
+ <tr>
+ <td class='string'>{{parcel.town}}</td>
+ <td>{{parcel.year}}</td>
+ <td>{{parcel.section}}</td>
+ <td>{{parcel.parcel_numbers|join:", "}}</td>
+ {#<td class='string'>{{operation.parcel.owner}}</td>#}
+ </tr>
+ {% empty %}
+ <tr><td colspan="4" class='no_items'>{% trans "No parcel associated to this operation" %}</td></tr>
+ {% endfor %}
+</table>
+
+<table>
+ <caption>{%trans "Admninistrative acts"%}</caption>
+ <tr>
+ <th>{% trans "Year" %}</th>
+ <th>{% trans "Reference" %}</th>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Date" %}</th>
+ </tr>
+ {% for act in item.administrative_act.all %}
+ <tr>
+ <td>{{act.signature_date.year}}</td>
+ <td>{{act.ref_sra}}</td>
+ <td class='string'>{{act.act_type}}</td>
+ <td>{{act.signature_date}}</td>
+ </tr>
+ {% empty %}
+ <tr><td colspan="4" class='no_items'>{% trans "No administrative act associated to this archaelogical file" %}</td></tr>
+ {% endfor %}
+</table>
+
+<table>
+ <caption>{%trans "Associated operations"%}</caption>
+ <tr>
+ <th>{% trans "Year" %}</th>
+ <th>{% trans "Reference" %}</th>
+ <th>Code Patriarche</th>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "In charge" %}</th>
+ <th>{% trans "Start date" %}</th>
+ <th>{% trans "Excavation end date" %}</th>
+ <th class='link'>&nbsp;</th>
+ </tr>
+ {% for operation in item.operations.all %}
+ <tr>
+ <td>{{operation.year}}</td>
+ <td>{{operation.operation_code}}</td>
+ <td>{{operation.code_patriarche|default:""}}</td>
+ <td class='string'>{{operation.operation_type}}</td>
+ <td class='string'>{{operation.in_charge|default:""}}</td>
+ <td>{{operation.start_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 %}
+ <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaelogical file" %}</td></tr>
+ {% endfor %}
+</table>
+
+<table>
+ <caption>{%trans "Admninistrative acts linked to associated operations"%}</caption>
+ <tr>
+ <th>{% trans "Year" %}</th>
+ <th>{% trans "Reference" %}</th>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Date" %}</th>
+ </tr>
+ {% for act in item.operation_acts %}
+ <tr>
+ <td>{{act.signature_date.year}}</td>
+ <td>{{act.ref_sra}}</td>
+ <td class='string'>{{act.act_type}}</td>
+ <td>{{act.signature_date}}</td>
+ </tr>
+ {% empty %}
+ <tr><td colspan="4" class='no_items'>{% trans "No administrative act linked to operations" %}</td></tr>
+ {% endfor %}
+</table>
+{% endblock %}
diff --git a/archaeological_files/templates/ishtar/sheet_file_pdf.html b/archaeological_files/templates/ishtar/sheet_file_pdf.html
new file mode 100644
index 000000000..29a4f4dec
--- /dev/null
+++ b/archaeological_files/templates/ishtar/sheet_file_pdf.html
@@ -0,0 +1,18 @@
+{% extends "ishtar/sheet_file.html" %}
+{% block css_head %}
+<link rel="stylesheet" href="{{MEDIA_URL}}/media/style_basic.css" />
+{% endblock %}
+{% block main_head %}
+{{ block.super }}
+<div id="pdfheader">
+Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
+</div>
+{% endblock %}
+{%block head_sheet%}{%endblock%}
+{%block main_foot%}
+<div id="pdffooter">
+&ndash; <pdf:pagenumber/> &ndash;
+</div>
+</body>
+</html>
+{%endblock%}
diff --git a/archaeological_files/templates/ishtar/sheet_file_window.html b/archaeological_files/templates/ishtar/sheet_file_window.html
new file mode 100644
index 000000000..e3486c052
--- /dev/null
+++ b/archaeological_files/templates/ishtar/sheet_file_window.html
@@ -0,0 +1,3 @@
+{% extends "ishtar/sheet_file.html" %}
+{% block main_head %}{%endblock%}
+{% block main_foot %}{%endblock%}
diff --git a/archaeological_files/views.py b/archaeological_files/views.py
index 3ef8c0f28..2b5003911 100644
--- a/archaeological_files/views.py
+++ b/archaeological_files/views.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -60,7 +60,11 @@ def autocomplete_file(request):
for file in files])
return HttpResponse(data, mimetype='text/plain')
-get_file = get_item(models.File, 'get_file', 'file')
+get_file = get_item(models.File, 'get_file', 'file',
+ extra_request_keys={'parcel_0':'operations__parcels__section',
+ 'parcel_1':'operations__parcels__parcel_number',
+ },
+ )
show_file = show_item(models.File, 'file')
revert_file = revert_item(models.File)
diff --git a/archaeological_files/wizards.py b/archaeological_files/wizards.py
index e2f6722ef..c475de47d 100644
--- a/archaeological_files/wizards.py
+++ b/archaeological_files/wizards.py
@@ -25,16 +25,18 @@ from django.template import RequestContext
from django.utils.translation import ugettext_lazy as _
from ishtar_common.wizards import Wizard, ClosingWizard
-from archaeological_operations.wizards import OperationAdministrativeActWizard,\
+from archaeological_operations.wizards import OperationWizard,\
+ OperationAdministrativeActWizard,\
AdministrativeActDeletionWizard
from ishtar_common.models import Town
from archaeological_operations.models import AdministrativeAct, Parcel, \
Operation
import models
-class FileWizard(Wizard):
+class FileWizard(OperationWizard):
model = models.File
object_parcel_type = 'associated_file'
+ parcel_step_key = 'parcels-'
def get_form(self, step=None, data=None, files=None):
"""
@@ -103,7 +105,7 @@ class FileWizard(Wizard):
continue
try:
dct['town'] = models.Town.objects.get(pk=int(dct['town']))
- except (ValueError, ObjectDoesNotExist):
+ except (ValueError, ObjectDoesNotExist, KeyError):
continue
dct['associated_file'], dct['operation'] = None, None
dct[self.object_parcel_type] = obj