summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_files/templates/ishtar/sheet_file.html23
-rw-r--r--archaeological_operations/models.py17
-rw-r--r--archaeological_operations/templates/ishtar/blocks/window_tables/administrativacts.html18
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html23
-rw-r--r--archaeological_operations/templatetags/__init__.py0
-rw-r--r--archaeological_operations/templatetags/window_ope_tables.py10
6 files changed, 48 insertions, 43 deletions
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 %}
</table>
-<table>
- <caption>{%trans "Admninistrative acts"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Ref." %}</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>
+{% trans "Administrativ acts" as administrativeacts_label %}
+{% table_administrativact administrativeacts_label item.administrative_act.all %}
<table>
<caption>{%trans "Associated operations"%}</caption>
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 %}
+<table>
+ <caption>{{caption}}</caption>
+ <tr>
+ <th>{% trans "Ref." %}</th>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Date" %}</th>
+ </tr>
+ {% for act in data %}
+ <tr>
+ <td>{{act.full_ref}}</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" %}</td></tr>
+ {% endfor %}
+</table>
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 %}
</table>
-<table>
- <caption>{%trans "Administrative acts"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Ref." %}</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>{% if act.ref_sra %}{{act.ref_sra}}{% endif %}</td>
- <td class='string'>{{act.act_type}}</td>
- <td class="string">{{act.signature_date}}</td>
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No acts associated to this operation" %}</td></tr>
- {% endfor %}
-</table>
+{% 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
--- /dev/null
+++ b/archaeological_operations/templatetags/__init__.py
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}
+