From 69b20d50aed1e20cb3a76652fac671efea4e3991 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 27 Sep 2022 17:13:44 +0200 Subject: Merge page - add more fields on table (refs #5447) --- CHANGES.md | 1 + ishtar_common/models.py | 4 -- ishtar_common/models_common.py | 55 +++++++++++++--------- ishtar_common/templates/ishtar/merge.html | 7 ++- .../templates/ishtar/merge_organization.html | 18 +++++-- ishtar_common/templates/ishtar/merge_person.html | 20 ++++++-- 6 files changed, 69 insertions(+), 36 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 510e51cdb..739eb2f87 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ v3.2.6 - 2022-09- ### Features ### - organization: add columns to table - add town search criteria +- merge pages: display all fields on table v3.2.5 - 2022-09-18 -------------------- diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 470ea4e72..366c467c8 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2412,10 +2412,6 @@ class Organization(Address, Merge, OwnPerms, BaseGenderedType, ValueGetter, Main self.merge_key = slugify(self.name or "") if not self.merge_key: self.merge_key = self.EMPTY_MERGE_KEY - if self.town: - self.merge_key += "-" + slugify(self.town or "") - if self.address: - self.merge_key += "-" + slugify(self.address or "") @property def associated_filename(self): diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index e164677ba..22244e4e2 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2248,38 +2248,51 @@ class Address(BaseHistorizedItem): lbl += self.address_lbl() return lbl - def address_lbl(self): - lbl = "" + def address_lbl(self, list=False): + lbls = [] prefix = "" if self.alt_address_is_prefered: prefix = "alt_" if getattr(self, prefix + "address"): - lbl += getattr(self, prefix + "address") + lbls.append(( + getattr(self, prefix + "address"), + _("Address") + )) if getattr(self, prefix + "address_complement"): - if lbl: - lbl += "\n" - lbl += getattr(self, prefix + "address_complement") + lbls.append(( + getattr(self, prefix + "address_complement"), + _("Address complement") + )) postal_code = getattr(self, prefix + "postal_code") town = getattr(self, prefix + "town") if postal_code or town: - if lbl: - lbl += "\n" - lbl += "{}{}{}".format( - postal_code or "", " " if postal_code and town else "", town or "" - ) + lbls.append(( + " ".join([postal_code, town]), + _("Postal code - Town") + )) if self.phone: - if lbl: - lbl += "\n" - lbl += "{} {}".format(str(_("Tel: ")), self.phone) + lbls.append(( + self.phone, + _("Phone") + )) if self.mobile_phone: - if lbl: - lbl += "\n" - lbl += "{} {}".format(str(_("Mobile: ")), self.mobile_phone) + lbls.append(( + self.mobile_phone, + _("Mobile") + )) if self.email: - if lbl: - lbl += "\n" - lbl += "{} {}".format(str(_("Email: ")), self.email) - return lbl + lbls.append(( + self.email, + _("Email") + )) + if list: + return lbls + return "\n".join([ + value for value, lbl in lbls + ]) + + def address_lbl_list(self): + return self.address_lbl(list=True) class Merge(models.Model): diff --git a/ishtar_common/templates/ishtar/merge.html b/ishtar_common/templates/ishtar/merge.html index 7f46231f1..a77ed2f91 100644 --- a/ishtar_common/templates/ishtar/merge.html +++ b/ishtar_common/templates/ishtar/merge.html @@ -39,7 +39,12 @@ {% endfor %} - + {% block "footer" %} + + {% endblock %} {% endblock %} diff --git a/ishtar_common/templates/ishtar/merge_organization.html b/ishtar_common/templates/ishtar/merge_organization.html index 10730e8c5..f2ce05b41 100644 --- a/ishtar_common/templates/ishtar/merge_organization.html +++ b/ishtar_common/templates/ishtar/merge_organization.html @@ -1,4 +1,4 @@ -{% extends "ishtar/merge.html" %} +{% extends "ishtar/merge.html" %}{% load i18n %} {% block merge_field_row %} {% if form.non_field_errors %}{% for error in form.non_field_errors %}{{error}} {% endfor%}{% endif %} @@ -6,15 +6,23 @@ - {{form.instance.from_organization}} ({{form.instance.from_organization.pk}})
- {{form.instance.from_organization.address_lbl|linebreaksbr}} + {{form.instance.from_organization.name}} ({{form.instance.from_organization.pk}})
+ {% if form.instance.from_organization.organization_type %}{{form.instance.from_organization.organization_type}}
{% endif %} + {% if form.instance.from_organization.url %}{{form.instance.from_organization.url}}
{% endif %} + {% for value, title in form.instance.from_organization.address_lbl_list %} + {{value}}{% if not forloop.last %}
{% endif %} + {% endfor %} - {{form.instance.to_organization}} ({{form.instance.to_organization.pk}})
- {{form.instance.to_organization.address_lbl|linebreaksbr}} + {{form.instance.to_organization.name}} ({{form.instance.to_organization.pk}})
+ {% if form.instance.to_organization.organization_type %}{{form.instance.to_organization.organization_type}}
{% endif %} + {% if form.instance.to_organization.url %}{{form.instance.to_organization.url}}
{% endif %} + {% for value, title in form.instance.to_organization.address_lbl_list %} + {{value}}{% if not forloop.last %}
{% endif %} + {% endfor %} {{form.b_is_duplicate_a}} {{form.a_is_duplicate_b}} diff --git a/ishtar_common/templates/ishtar/merge_person.html b/ishtar_common/templates/ishtar/merge_person.html index 0d03112c5..bb80a5645 100644 --- a/ishtar_common/templates/ishtar/merge_person.html +++ b/ishtar_common/templates/ishtar/merge_person.html @@ -1,4 +1,4 @@ -{% extends "ishtar/merge.html" %} +{% extends "ishtar/merge.html" %}{% load i18n %} {% block merge_field_row %} {% if form.non_field_errors %}{% for error in form.non_field_errors %}{{error}} {% endfor%}{% endif %} @@ -6,15 +6,25 @@ - {{form.instance.from_person}} ({{form.instance.from_person.pk}})
- {{form.instance.from_person.address_lbl|linebreaksbr}} + {{form.instance.from_person.raw_name}} ({{form.instance.from_person.pk}})
+ {{form.instance.from_person.title|default:""}} {{form.instance.from_person.name|default:""}} {{form.instance.from_person.surname|default:""}}
+ {% if form.instance.from_person.attached_to %}{{form.instance.from_person.attached_to}}
{% endif %} + {% if form.instance.from_person.salutation %}{{form.instance.from_person.salutation}}
{% endif %} + {% for value, title in form.instance.from_person.address_lbl_list %} + {{value}}{% if not forloop.last %}
{% endif %} + {% endfor %} - {{form.instance.to_person}} ({{form.instance.to_person.pk}})
- {{form.instance.to_person.address_lbl|linebreaksbr}} + {{form.instance.to_person.raw_name}} ({{form.instance.to_person.pk}})
+ {{form.instance.to_person.title|default:""}} {{form.instance.to_person.name|default:""}} {{form.instance.to_person.surname|default:""}}
+ {% if form.instance.to_person.attached_to %}{{form.instance.to_person.attached_to}}
{% endif %} + {% if form.instance.to_person.salutation %}{{form.instance.to_person.salutation}}
{% endif %} + {% for value, title in form.instance.to_person.address_lbl_list %} + {{value}}{% if not forloop.last %}
{% endif %} + {% endfor %} {{form.b_is_duplicate_a}} {{form.a_is_duplicate_b}} -- cgit v1.2.3