diff options
-rw-r--r-- | ishtar/furnitures/forms.py | 4 | ||||
-rw-r--r-- | ishtar/furnitures/models.py | 13 | ||||
-rw-r--r-- | ishtar/furnitures/urls.py | 3 | ||||
-rw-r--r-- | ishtar/furnitures/views.py | 4 | ||||
-rw-r--r-- | ishtar/templates/default_wizard.html | 1 | ||||
-rw-r--r-- | ishtar/templates/sheet.html | 9 | ||||
-rw-r--r-- | ishtar/templates/sheet_file.html | 4 | ||||
-rw-r--r-- | ishtar/templates/sheet_operation.html | 128 | ||||
-rw-r--r-- | ishtar/templates/sheet_operation_pdf.html | 14 | ||||
-rw-r--r-- | ishtar/templates/sheet_operation_window.html | 3 | ||||
-rw-r--r-- | static/js/ishtar.js | 6 | ||||
-rw-r--r-- | static/media/style.css | 13 |
12 files changed, 186 insertions, 16 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 642da9b4b..821ef1bb9 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -1631,10 +1631,7 @@ class RecordWizard(Wizard): r = super(RecordWizard, self).done(request, storage, form_list, return_object=True, **kwargs) if type(r) not in (list, tuple) or len(r) != 2: - print 1 - print r return r - print 2 obj, res = r for form in form_list: if not hasattr(form, 'prefix') \ @@ -1646,7 +1643,6 @@ class RecordWizard(Wizard): if not frm.is_valid(): continue dct = frm.cleaned_data.copy() - print dct if not dct: continue try: diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index c1980f68c..b9dc19afe 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -449,6 +449,16 @@ class Operation(BaseHistorizedItem, OwnPerms): return Q(in_charge=user.person)|Q(history_modifier=user)\ & Q(end_date__isnull=True) + """ + def closing(self): + if self.is_active: + return + for item in self.history.all(): + if item.is_active(): + break + closing_item = item + return {'date':item.history_date, 'user':item.history_modifier} +""" class Parcel(LightHistorizedItem): associated_file = models.ForeignKey(File, related_name='parcels', blank=True, null=True, verbose_name=_(u"File")) @@ -549,7 +559,8 @@ class Unit(GeneralType) : return self.label class ContextRecord(BaseHistorizedItem, OwnPerms): - parcel = models.ForeignKey(Parcel, verbose_name=_(u"Parcel")) + parcel = models.ForeignKey(Parcel, verbose_name=_(u"Parcel"), + related_name='context_records') label = models.CharField(_(u"Label"), max_length=200) description = models.TextField(_("Description"), blank=True, null=True) lenght = models.IntegerField(_(u"Lenght")) diff --git a/ishtar/furnitures/urls.py b/ishtar/furnitures/urls.py index 0e28043e2..71a3a116c 100644 --- a/ishtar/furnitures/urls.py +++ b/ishtar/furnitures/urls.py @@ -98,6 +98,9 @@ urlpatterns += patterns('ishtar.furnitures.views', url(BASE_URL + r'show-operation/(?P<pk>.+)?/(?P<type>.+)?$', 'show_operation', name='show-operation'), + url(BASE_URL + r'show-contextrecord/(?P<pk>.+)?/(?P<type>.+)?$', + 'show_contextrecord', + name='show-contextrecord'), url(BASE_URL + r'update-current-item/$', 'update_current_item', name='update-current-item'), url(BASE_URL + r'get-administrativeact/(?P<type>.+)?$', diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py index 1be067454..b22257839 100644 --- a/ishtar/furnitures/views.py +++ b/ishtar/furnitures/views.py @@ -246,6 +246,8 @@ def show_item(model, name): return HttpResponse(None) doc_type = 'type' in dct and dct.pop('type') dct['item'], dct['item_name'] = item, name + dct['window_id'] = "%s-%d-%s" % (name, item.pk, + datetime.datetime.now().strftime('%M%s')) context_instance = RequestContext(request) context_instance.update(dct) n = datetime.datetime.now() @@ -374,6 +376,8 @@ def autocomplete_organization(request, orga_type=None): for org in organizations]) return HttpResponse(data, mimetype='text/plain') +show_contextrecord = show_item(models.ContextRecord, 'contextrecord') + def action(request, action_slug, obj_id=None, *args, **kwargs): """ Action management diff --git a/ishtar/templates/default_wizard.html b/ishtar/templates/default_wizard.html index 1666b4979..70563786b 100644 --- a/ishtar/templates/default_wizard.html +++ b/ishtar/templates/default_wizard.html @@ -14,6 +14,7 @@ </ul> <div class='form'> {% if form.forms %} +<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div> <table class='formset'> {%if form.non_form_errors%}<tr class='error'><th colspan='2'>{{form.non_form_errors}}</th></tr>{%endif%} {{ form.management_form }} diff --git a/ishtar/templates/sheet.html b/ishtar/templates/sheet.html index c157b61a0..8da56345c 100644 --- a/ishtar/templates/sheet.html +++ b/ishtar/templates/sheet.html @@ -12,8 +12,13 @@ </head> <body> {% endblock %} -<div class="sheet"> -<div class="head"><a href='#' onclick='$("#window").hide("slow")'>{% trans "Close" %}</a></div> +<div class="sheet" id='{{window_id}}'> +<script type="text/javascript">var last_window='{{window_id}}';</script> +<div class="head"> +<a href='#' onclick='$("#{{window_id}}").hide("slow")'>{% trans "Close" %}</a> - +<a href='#' onclick='$("#window > div").hide("slow");$("#window").html("")'> +{% trans "Close all windows" %} +</a></div> <div class="body"> {% block content %}{% endblock %} </div> diff --git a/ishtar/templates/sheet_file.html b/ishtar/templates/sheet_file.html index 314fcaf06..8a004b0a5 100644 --- a/ishtar/templates/sheet_file.html +++ b/ishtar/templates/sheet_file.html @@ -25,7 +25,7 @@ <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='{% 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.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> @@ -91,7 +91,7 @@ <td class='string'>{{operation.in_charge|default:""}}</td> <td>{{operation.start_date|default:""}}</td> <td>{{operation.end_date|default:""}}</td> - <td class='link'><a href="#{#{%url show-operation operation.pk%}#}">{% trans "Details" %}</a></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> diff --git a/ishtar/templates/sheet_operation.html b/ishtar/templates/sheet_operation.html new file mode 100644 index 000000000..d0e31ae5a --- /dev/null +++ b/ishtar/templates/sheet_operation.html @@ -0,0 +1,128 @@ +{% extends "sheet.html" %} +{% load i18n %} +{% block content %} +<div class='tool'>{%trans "Export as:"%} <a href='{% url show-operation item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-operation 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.operation_code }}</span></p> + +{% if item.code_patriarche %}<p><label>{%trans "Patriarche OA code:"%}</label> <span class='value'>{{ item.code_patriarche }}</span></p>{%else%} +<p class='alert'>{%trans "Patriarche OA code not yet recorded!"%}</p>{%endif%} + +{#<p><label>{%trans "Operation's name:"%}</label> <span class='value'>{{ item.internal_reference }}</span></p>#} + +<p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history.all.0.history_date }}</span></p> <!-- date = now --> + +<p><label>{%trans "Begining date:"%}</label> <span class='value'>{{ item.start_date }}</span></p> +<p><label>{%trans "Field work end's date:"%}</label> <span class='value'>{{ item.end_date }}</span></p> + +<p><label>{%trans "Head scientist:"%}</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 operation"%}</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.operation_type }}</span></p> +{#<p><label>{%trans "Surface:"%}</label> <span class='value'>{{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha)</span></p>#} +{% if item.cost %}<p><label>{%trans "Cost:"%}</label> <span class='value'>{{ item.cost }} Euros, ({{ item.cost_by_m2 }} Euros/m<sup>2</sup>)</span></p>{%endif%} +{% if item.duration %}<p><label>{%trans "Duration:"%}</label> <span class='value'>{{ item.duration }} {%trans "Day"%}s</span></p>{%endif%} + +<p><label>{%trans "Remains:"%}</label> <span class='value'>{{ item.remains.all|join:", " }}</span></p> +<p><label>{%trans "Periods:"%}</label> <span class='value'>{{ item.periods.all|join:", " }}</span></p> + +{% if item.associated_file %} +<p><label>{%trans "Associated file:"%}</label> <span class='value'><a href='#' onclick='load_window("{% url show-file item.associated_file.pk ''%}")'>{{ item.associated_file }}</a></span></p><!-- Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related file --> +{% if item.associated_file.is_preventive %} +{#{% if item.operator_reference_code %}<p><label>{%trans "Operator's reference code:"%}</label> <span class='value'>{{ item.operator_reference_code }}</span></p>{% endif %}#} +{% if item.associated_file.town_planning_service %}<p><label>{%trans "Town planning service:"%}</label> <span class='value'>{{ item.associated_file.town_planning_service }}</span></p>{% endif %} +{% if item.associated_file.permit_type %}<p><label>{%trans "Permit type:"%}</label> <span class='value'>{{ item.associated_file.permit_type }}</span></p>{% endif %} +{% if item.associated_file.permit_reference %}<p><label>{%trans "Permit reference:"%}</label> <span class='value'>{{ item.associated_file.permit_reference }}</span></p>{% endif %} +{% if item.associated_file.general_contractor.attached_to %}<p><label>{%trans "General contractor organisation:"%}</label> <span class='value'>{{ item.associated_file.general_contractor.attached_to }}</span></p>{% endif %} <!-- Contractor's organisation displayed as concat of Name/Adress/postal_code/city --> +{% if item.associated_file.general_contractor %}<p><label>{%trans "General contractor:"%}</label> <span class='value'>{{ item.associated_file.general_contractor.full_label }}</span></p>{% endif %} +{% endif %} +{% endif %} + +{% 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.associated_file.address }}</span></p> +{% if item.associated_file.address_complement %}<p><label>{%trans "Complement:"%}</label> <span class='value'>{{ item.associated_file.address_complement }}</span></p>{%endif%} +{% if item.associated_file.postal_code %}<p><label>{%trans "Postal code:"%}</label> <span class='value'>{{ item.associated_file.postal_code }}</span></p>{%endif%} + +{% comment %} +<p><label>{%trans "Lambert X:"%}</label> <span class='value'>{{ item.lambert_x }}</span></p> +<p><label>{%trans "Lambert Y:"%}</label> <span class='value'>{{ item.lambert_y }}</span></p> +<p><label>{%trans "Altitude (m NGF):"%}</label> <span class='value'>{{ item.altitude }}</span></p> +{% endcomment %} +<table> + <caption>{%trans "Associated parcels"%}</caption> + <tr> + <th>{% trans "Commune" %}</th> + <th>{% trans "Year" %}</th> + <th>{% trans "Section" %}</th> + <th>{% trans "Parcel" %}</th> + {#<th>{% trans "Owner" %}</th>#} + </tr> + {% for parcel in item.parcels.all %} + <tr> + <td class='string'>{{parcel.town}}</td> + <td>{{parcel.year}}</td> + <td>{{parcel.section}}</td> + <td>{{parcel.parcel_number}}</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 operation" %}</td></tr> + {% endfor %} +</table> + +<table> + <caption>{%trans "Context records"%}</caption> + <tr> + <th>{% trans "Label" %}</th> + <th>{% trans "Type" %}</th> + <th>{% trans "Chronology" %}</th> + <th>{% trans "Description" %}</th> + <th>{% trans "Parcel" %}</th> + <th class='link'> </th> + </tr> + {% for parcel in item.parcels.all %} + {% for context_record in item.context_record.all %} + <tr> + <td>{{ context_record.label }}</td> + <td class='string'>{{context_record.unit}}</td> + <td>{{ context_record.datings.all|join:", " }}</td>{# periods ?#} + <td class='string'>{{ context_record.description }}</td> + <td>{{ parcel.section }} - {{parcel.parcel_number}}</td> + <td class='link'><a href="#" onclick='load_window("{%url show-context_record context_record.pk%}")'>{% trans "Details" %}</a></td> + </tr> + {% empty %} + <tr><td colspan="5" class='no_items'>{% trans "No context record associated to parcel " %}{{ parcel.section }} - {{parcel.parcel_number}}</td></tr> + {% endfor %} + {% empty %} + <tr><td colspan="5" class='no_items'>{% trans "No context record associated to this operation" %}</td></tr> + {% endfor %} +</table> + +{% endblock %} diff --git a/ishtar/templates/sheet_operation_pdf.html b/ishtar/templates/sheet_operation_pdf.html new file mode 100644 index 000000000..30f9595bf --- /dev/null +++ b/ishtar/templates/sheet_operation_pdf.html @@ -0,0 +1,14 @@ +{% extends "sheet_operation.html" %} +{% block main_head %} +{{ block.super }} +<div id="pdfheader"> +Ishtar – {{APP_NAME}} – {{item}} +</div> +{% endblock %} +{%block main_foot%} +<div id="pdffooter"> +– <pdf:pagenumber/> – +</div> +</body> +</html> +{%endblock%} diff --git a/ishtar/templates/sheet_operation_window.html b/ishtar/templates/sheet_operation_window.html new file mode 100644 index 000000000..9c595a1e9 --- /dev/null +++ b/ishtar/templates/sheet_operation_window.html @@ -0,0 +1,3 @@ +{% extends "sheet_operation.html" %} +{% block main_head %}{%endblock%} +{% block main_foot %}{%endblock%} diff --git a/static/js/ishtar.js b/static/js/ishtar.js index 7dc1be345..784480f81 100644 --- a/static/js/ishtar.js +++ b/static/js/ishtar.js @@ -45,13 +45,15 @@ $("#main_menu ul li").live('click', function(){ $(this).find('ul').show('slow'); }); +var last_window; + function load_window(url){ $.ajax({ url: url, cache: false, success:function(html){ - $("#window").html(html); - $("#window").show('slow'); + $("#window").append(html); + $("#"+last_window).show('slow'); }, error:function(XMLHttpRequest, textStatus, errorThrows){ } diff --git a/static/media/style.css b/static/media/style.css index 5d00ff793..7868a4671 100644 --- a/static/media/style.css +++ b/static/media/style.css @@ -249,7 +249,7 @@ table.confirm tr.spacer td:last-child{ color:#D14; } -#window{ +.sheet{ width:760px; position:fixed; height:90%; @@ -299,10 +299,6 @@ table.confirm tr.spacer td:last-child{ font-style:italic; } -#window .sheet{ -} - - #window .head{ text-align:center; background-color:#EEE; @@ -343,3 +339,10 @@ table.confirm tr.spacer td:last-child{ margin:0.3em; } +#window p.alert{ + color:#D14; + display:block; + margin-left:1em; + font-style:italic; +} + |