From 61cc73ab79d433ee716b4bb7fbe834c3e9379b8f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 13 Jan 2014 11:05:15 +0100 Subject: Add created by to record cart (refs #1590) --- .../templates/ishtar/sheet_contextrecord.html | 2 ++ archaeological_files/templates/ishtar/sheet_file.html | 1 + .../templates/ishtar/sheet_administrativeact.html | 2 +- .../templates/ishtar/sheet_operation.html | 1 + ishtar_common/models.py | 19 +++++++++++++++++-- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index 06528c4d2..ee1719eda 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -29,6 +29,8 @@

{%endif%} {{item.full_label}}

+

{{ item.creation_date }}

+

{{ item.created_by.full_label }}

{%if item.unit %}

{{ item.unit }}

{%endif%} diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index e8ddca99a..40ac707d6 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -31,6 +31,7 @@

{{ item.history_date }}

{% if item.reception_date %}

{{ item.reception_date }}

{% endif %}

{{ item.creation_date }}

+

{{ item.created_by.full_label }}

{% comment %} {% if item.deadline_date and not item.acts %}

{% item.deadline_date %}

diff --git a/archaeological_operations/templates/ishtar/sheet_administrativeact.html b/archaeological_operations/templates/ishtar/sheet_administrativeact.html index e44dc4aea..da80f6747 100644 --- a/archaeological_operations/templates/ishtar/sheet_administrativeact.html +++ b/archaeological_operations/templates/ishtar/sheet_administrativeact.html @@ -16,11 +16,11 @@

{{ item.in_charge.full_label }}

{% if item.operator %}

{{ item.operator }}

{% endif %} -{% comment %}

{{ item.creation_date }}

{% endcomment %} {% if item.associated_file %}

{{ item.associated_file }}

{% endif %} {% if item.operation %}

{{ item.operation }}

{% endif %} {% if item.operation %}{% if item.operation.surface %}

{{ item.operation.surface }} m2 ({{ item.operation.surface_ha }} ha)

{%endif%} {% endif %} +

{{ item.created_by.full_label }}

{%comment%}{% if item.general_contractor.attached_to %}

{{ item.general_contractor.attached_to }}

{% endif %} {% if item.general_contractor %}

{{ item.general_contractor.full_label }}

{% endif %} {%endcomment%} diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index e1846c8e2..9d9b845e3 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -34,6 +34,7 @@

{%trans "Patriarche OA code not yet recorded!"%}

{%endif%}

{{ item.history.all.0.history_date }}

+

{{ item.created_by.full_label }}

{% if item.start_date %}

{{ item.start_date }}

{{ item.excavation_end_date|default:"-" }}

diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b7553d911..811e2e63b 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -440,6 +440,17 @@ class BaseHistorizedItem(models.Model): except IndexError: return + @property + def created_by(self): + q = self.history.order_by('history_date') + if not q.count(): + return + try: + modifier = IshtarUser.objects.get(pk=q.all()[0].history_modifier_id) + return modifier.person + except IshtarUser.DoesNotExist: + return + def rollback(self, date): """ Rollback to a previous state @@ -767,8 +778,10 @@ class Person(Address, OwnPerms, ValueGetter) : def __unicode__(self): values = [unicode(getattr(self, attr)) - for attr in ('surname', 'name', 'attached_to') + for attr in ('surname', 'name') if getattr(self, attr)] + if self.attached_to: + values.append(u"- " + unicode(self.attached_to)) return u" ".join(values) def get_values(self, prefix=''): @@ -806,8 +819,10 @@ class Person(Address, OwnPerms, ValueGetter) : if self.title: values = [unicode(_(self.title))] values += [unicode(getattr(self, attr)) - for attr in ('surname', 'name', 'attached_to') + for attr in ('surname', 'name') if getattr(self, attr)] + if self.attached_to: + values.append(u"- " + unicode(self.attached_to)) return u" ".join(values) @property -- cgit v1.2.3