From bcb27ee5d77a8d60e25443f9aef59c395b4cee06 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 16 Jan 2014 20:49:57 +0100 Subject: Improve layout of administrativ acts in tables and record carts (refs #1621) --- .../templates/ishtar/sheet_file.html | 23 +++------------------- archaeological_operations/models.py | 17 +++++++++++++--- .../blocks/window_tables/administrativacts.html | 18 +++++++++++++++++ .../templates/ishtar/sheet_operation.html | 23 +++------------------- archaeological_operations/templatetags/__init__.py | 0 .../templatetags/window_ope_tables.py | 10 ++++++++++ 6 files changed, 48 insertions(+), 43 deletions(-) create mode 100644 archaeological_operations/templates/ishtar/blocks/window_tables/administrativacts.html create mode 100644 archaeological_operations/templatetags/__init__.py create mode 100644 archaeological_operations/templatetags/window_ope_tables.py diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 40ac707d6..dcf58da09 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -1,5 +1,5 @@ {% extends "ishtar/sheet.html" %} -{% load i18n %} +{% load i18n window_ope_tables %} {% block head_sheet %} {{block.super}} @@ -93,25 +93,8 @@ {% endfor %} - - - - - - - - - {% for act in item.administrative_act.all %} - - - - - - - {% empty %} - - {% endfor %} -
{%trans "Admninistrative acts"%}
{% trans "Year" %}{% trans "Ref." %}{% trans "Type" %}{% trans "Date" %}
{{act.signature_date.year}}{{act.ref_sra}}{{act.act_type}}{{act.signature_date}}
{% trans "No administrative act associated to this archaelogical file" %}
+{% trans "Administrativ acts" as administrativeacts_label %} +{% table_administrativact administrativeacts_label item.administrative_act.all %} diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index bbffe023f..aa72d24ec 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -391,10 +391,11 @@ class ActType(GeneralType): ordering = ('label',) class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): - TABLE_COLS = ['year', 'index', 'act_type', 'signature_date', + TABLE_COLS = ['full_ref', 'act_type', 'signature_date', 'associated_file', 'operation'] - TABLE_COLS_FILE = ['act_type', 'associated_file', 'associated_file.towns',] - TABLE_COLS_OPE = ['act_type', 'operation', 'operation.towns'] + TABLE_COLS_FILE = ['full_ref', 'act_type', 'associated_file', + 'associated_file.towns',] + TABLE_COLS_OPE = ['full_ref', 'act_type', 'operation', 'operation.towns'] act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type")) in_charge = models.ForeignKey(Person, blank=True, null=True, related_name='+', verbose_name=_(u"Person in charge of the operation")) @@ -442,6 +443,16 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): for item in [self.operation, self.associated_file, self.act_object] if item]) + full_ref_lbl = _(u"Ref.") + @property + def full_ref(self): + keys = ['year', 'index'] + if settings.COUNTRY == 'fr': + keys.append('ref_sra') + return settings.JOINT.join( + [getattr(self, k) and unicode(getattr(self, k)) or '-' + for k in keys]) + @property def year(self): if not self.signature_date: diff --git a/archaeological_operations/templates/ishtar/blocks/window_tables/administrativacts.html b/archaeological_operations/templates/ishtar/blocks/window_tables/administrativacts.html new file mode 100644 index 000000000..9feb51e72 --- /dev/null +++ b/archaeological_operations/templates/ishtar/blocks/window_tables/administrativacts.html @@ -0,0 +1,18 @@ +{% load i18n %} +
{%trans "Associated operations"%}
+ + + + + + + {% for act in data %} + + + + + + {% empty %} + + {% endfor %} +
{{caption}}
{% trans "Ref." %}{% trans "Type" %}{% trans "Date" %}
{{act.full_ref}}{{act.act_type}}{{act.signature_date}}
{% trans "No administrative act associated" %}
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index 9d9b845e3..77e4f1f1d 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -1,5 +1,5 @@ {% extends "ishtar/sheet.html" %} -{% load i18n window_tables %} +{% load i18n window_tables window_ope_tables %} {% block head_sheet %} {{block.super}} @@ -100,25 +100,8 @@ {% endfor %} - - - - - - - - - {% for act in item.administrative_act.all %} - - - - - - - {% empty %} - - {% endfor %} -
{%trans "Administrative acts"%}
{% trans "Year" %}{% trans "Ref." %}{% trans "Type" %}{% trans "Date" %}
{{act.signature_date.year}}{% if act.ref_sra %}{{act.ref_sra}}{% endif %}{{act.act_type}}{{act.signature_date}}
{% trans "No acts associated to this operation" %}
+{% trans "Administrativ acts" as administrativeacts_label %} +{% table_administrativact administrativeacts_label item.administrative_act.all %} {% trans "Document from this operation" as operation_docs %} {% if item.source.count %} {% table_document operation_docs item.source.all %}{% endif %} diff --git a/archaeological_operations/templatetags/__init__.py b/archaeological_operations/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/archaeological_operations/templatetags/window_ope_tables.py b/archaeological_operations/templatetags/window_ope_tables.py new file mode 100644 index 000000000..5576fe32d --- /dev/null +++ b/archaeological_operations/templatetags/window_ope_tables.py @@ -0,0 +1,10 @@ +from django import template +from django.utils.translation import ugettext as _ +import re + +register = template.Library() + +@register.inclusion_tag('ishtar/blocks/window_tables/administrativacts.html') +def table_administrativact(caption, data): + return {'caption':caption, 'data':data} + -- cgit v1.2.3