From 5abe9dcdfc37493be0596d49c1ce8aa8266f2e34 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 13 Jan 2016 17:13:44 +0100 Subject: Sheets: Full address display for organizations and persons --- .../templates/ishtar/sheet_file.html | 29 ++++++++++++++------ .../templates/ishtar/sheet_operation.html | 19 ++++++++++--- ishtar_common/models.py | 31 +++++++++++++++++++--- .../templates/ishtar/blocks/window_field.html | 2 +- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 10ee82232..67341c07d 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -76,14 +76,27 @@

{% trans "Preventive archaelogical file"%}

{% if item.total_developed_surface %}

{{ item.total_developed_surface }} m2 ({{ item.total_developed_surface_ha }} ha)

{% endif %} -

{{ item.saisine_type }}

-{% if item.town_planning_service %}

{{ item.town_planning_service }}

{% endif %} -{% if item.permit_type %}

{{ item.permit_type }}

{% endif %} -{% if item.permit_reference %}

{{ item.permit_reference }}

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

{{ item.general_contractor.attached_to }}

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

{{ item.general_contractor.full_label }}

{% endif %} - -{%else%} + +{% field "Saisine type" item.saisine_type %} + +{% field "Responsible for town planning service" item.responsible_town_planning_service.full_address %} +{% if item.town_planning_service %} + {% field "Town planning service organization" item.town_planning_service.full_address %} +{% else %} + {% field "Town planning service organization" item.responsible_town_planning_service.attached_to.full_address %} +{% endif %} + +{% field "Permit type" item.permit_type %} +{% field "Permit reference" item.reference %} + +{% field "General contractor" item.general_contractor.full_address %} +{% if item.corporation_general_contractor %} + {% field "General contractor organization" item.corporation_general_contractor.full_address %} +{% else%} + {% field "General contractor organization" item.general_contractor.attached_to.full_address %} +{% endif %} + +{% else %}

{% trans "Research archaeology"%}

{% if item.departments.count %}

{% for department in item.departments.all %}{% if forloop.counter0 %}, {% endif %}{{ department }}{% endfor %}

{% endif %} diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index e3a53e5fa..c0beac524 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -73,11 +73,24 @@

{{ item.associated_file }}

{% if item.associated_file.is_preventive %} {#{% if item.operator_reference_code %}

{{ item.operator_reference_code }}

{% endif %}#} -{% if item.associated_file.town_planning_service %}

{{ item.associated_file.town_planning_service }}

{% endif %} + +{% field "Responsible for town planning service" item.associated_file.responsible_town_planning_service.full_address %} +{% if item.associated_file.town_planning_service %} + {% field "Town planning service organization" item.associated_file.town_planning_service.full_address %} +{% else %} + {% field "Town planning service organization" item.associated_file.responsible_town_planning_service.attached_to.full_address %} +{% endif %} + {% if item.associated_file.permit_type %}

{{ item.associated_file.permit_type }}

{% endif %} {% if item.associated_file.permit_reference %}

{{ item.associated_file.permit_reference }}

{% endif %} -{% if item.associated_file.general_contractor.attached_to %}

{{ item.associated_file.general_contractor.attached_to }}

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

{{ item.associated_file.general_contractor.full_label }}

{% endif %} + +{% field "General contractor" item.associated_file.general_contractor.full_address %} +{% if item.associated_file.corporation_general_contractor %} + {% field "General contractor organization" item.associated_file.corporation_general_contractor.full_address %} +{% else%} + {% field "General contractor organization" item.associated_file.general_contractor.attached_to.full_address %} +{% endif %} + {% endif %} {% endif %} diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 2745bf4b6..61376e079 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1069,8 +1069,18 @@ class Address(BaseHistorizedItem): class Meta: abstract = True + def simple_lbl(self): + return unicode(self) + + def full_address(self): + lbl = self.simple_lbl() + if lbl: + lbl += u"\n" + lbl += self.address_lbl() + return lbl + def address_lbl(self): - lbl = '' + lbl = u'' if self.address: lbl += self.address if self.address_complement: @@ -1085,11 +1095,11 @@ class Address(BaseHistorizedItem): " " if self.postal_code and self.town else '', self.town or '') if self.phone: - lbl += "{}{}".format(_("Tel:"), self.phone) + lbl += "{}{}".format(unicode(_("Tel:")), self.phone) if self.mobile_phone: - lbl += "{}{}".format(_("Mobile: "), self.mobile_phone) + lbl += "{}{}".format(unicode(_("Mobile: ")), self.mobile_phone) if self.email: - lbl += "{}{}".format(_("Email: "), self.email) + lbl += "{}{}".format(unicode(_("Email: ")), self.email) return lbl @@ -1880,6 +1890,12 @@ class Organization(Address, Merge, OwnPerms, ValueGetter): ugettext(u"Can delete own Organization")), ) + def simple_lbl(self): + if self.name: + return self.name + return u"{} - {}".format(self.organization_type, + self.town or "") + def __unicode__(self): if self.name: return self.name @@ -1949,6 +1965,13 @@ class Person(Address, Merge, OwnPerms, ValueGetter): ("delete_own_person", ugettext(u"Can delete own Person")), ) + def simple_lbl(self): + values = [unicode(getattr(self, attr)) for attr in ('surname', 'name') + if getattr(self, attr)] + if not values and self.raw_name: + values = [self.raw_name] + return u" ".join(values) + def __unicode__(self): values = [unicode(getattr(self, attr)) for attr in ('surname', 'name') if getattr(self, attr)] diff --git a/ishtar_common/templates/ishtar/blocks/window_field.html b/ishtar_common/templates/ishtar/blocks/window_field.html index bca32225c..14cf1c21e 100644 --- a/ishtar_common/templates/ishtar/blocks/window_field.html +++ b/ishtar_common/templates/ishtar/blocks/window_field.html @@ -1,3 +1,3 @@ {% load i18n %} {% if data %}

-{{pre_data|safe}}{{data}}{{post_data|safe}}

{% endif%} +{{pre_data|safe}}{{data|linebreaksbr}}{{post_data|safe}}

{% endif%} -- cgit v1.2.3