From 26fd95c723cec410e179362f2c86ea1e7b527e3d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 12 May 2014 22:57:10 +0200 Subject: Fix created by fields on sheets (refs #1590) --- .../templates/ishtar/sheet_contextrecord.html | 2 +- archaeological_files/templates/ishtar/sheet_file.html | 2 +- archaeological_finds/templates/ishtar/sheet_find.html | 1 + .../templates/ishtar/sheet_administrativeact.html | 2 +- .../templates/ishtar/sheet_operation.html | 2 +- ishtar_common/models.py | 14 +++----------- ishtar_common/templates/ishtar/sheet_organization.html | 1 + ishtar_common/templates/ishtar/sheet_person.html | 1 + 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index 95a44116d..acc0db718 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -30,7 +30,7 @@ {%endif%} {{item.full_label}}

{{ item.creation_date }}

-

{{ item.created_by.full_label }}

+

{{ item.history_creator.ishtaruser.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 dddae309b..ffbf0018f 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -31,7 +31,7 @@

{{ item.history_date }}

{% if item.reception_date %}

{{ item.reception_date }}

{% endif %}

{{ item.creation_date }}

-

{{ item.created_by.full_label }}

+

{{ item.history_creator.ishtaruser.full_label }}

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

{% item.deadline_date %}

diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 89f335e1a..0e5ddfac0 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -32,6 +32,7 @@ {{item.label}}

{% if item.description %}

{{item.description}}

{% endif%} +

{{ item.history_creator.ishtaruser.full_label }}

{{item.material_type}}

diff --git a/archaeological_operations/templates/ishtar/sheet_administrativeact.html b/archaeological_operations/templates/ishtar/sheet_administrativeact.html index 2cceb0222..0457d9260 100644 --- a/archaeological_operations/templates/ishtar/sheet_administrativeact.html +++ b/archaeological_operations/templates/ishtar/sheet_administrativeact.html @@ -21,7 +21,7 @@ {% 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 }}

+

{{ item.history_creator.ishtaruser.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 fe92314c2..0fd2a1076 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -34,7 +34,7 @@

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

{%endif%}

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

-

{{ item.created_by.full_label }}

+

{{ item.history_creator.ishtaruser.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 4e05a115f..1aaaf933a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -453,17 +453,6 @@ 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 @@ -882,6 +871,9 @@ class IshtarUser(User): def has_right(self, right_name): return self.person.has_right(right_name) + def full_label(self): + return self.person.full_label() + class AuthorType(GeneralType): class Meta: verbose_name = _(u"Author type") diff --git a/ishtar_common/templates/ishtar/sheet_organization.html b/ishtar_common/templates/ishtar/sheet_organization.html index e58d84887..c5f01b96a 100644 --- a/ishtar_common/templates/ishtar/sheet_organization.html +++ b/ishtar_common/templates/ishtar/sheet_organization.html @@ -10,6 +10,7 @@
{%trans "Export as:"%} {%trans "OpenOffice.org file"%}, {%trans "PDF file"%}

{{item.name}}

+

{{ item.history_creator.ishtaruser.full_label }}

{% if item.address %}

{{item.address}}

{% endif %} {% if item.address_complement %}

{{item.address_complement}}

{% endif %} {% if item.postal_code %}

{{item.postal_code}}

{% endif %} diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index 1fc31ac23..b6bf99d56 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -11,6 +11,7 @@

{{item.name}}

{{item.surname}}

+

{{ item.history_creator.ishtaruser.full_label }}

{% if item.email %}

{{item.email}}

{% endif %}

{{item.person_types_list}}

{% if item.address %}

{{item.address}}

{% endif %} -- cgit v1.2.3