diff --git a/integreat_cms/cms/models/contact/contact.py b/integreat_cms/cms/models/contact/contact.py index ecbba18787..896b51fd24 100644 --- a/integreat_cms/cms/models/contact/contact.py +++ b/integreat_cms/cms/models/contact/contact.py @@ -90,6 +90,21 @@ def get_additional_attribute(self) -> str: return "" + def label_in_reference_list(self) -> str: + """ + This function returns + """ + + label = ( + _("General contact information") + if not self.point_of_contact_for + else f"{self.point_of_contact_for} {self.name}" + ) + if self.archived: + label += " (⚠ " + gettext("Archived") + ")" + + return label + def get_repr(self) -> str: """ This overwrites the default Django ``__repr__()`` method which would return ````. diff --git a/integreat_cms/cms/templates/pois/poi_form_sidebar/action_box.html b/integreat_cms/cms/templates/pois/poi_form_sidebar/action_box.html index 327e4e85a9..7f1be1f1fe 100644 --- a/integreat_cms/cms/templates/pois/poi_form_sidebar/action_box.html +++ b/integreat_cms/cms/templates/pois/poi_form_sidebar/action_box.html @@ -68,7 +68,7 @@ {% for contact in poi_form.instance.contacts.all %} - {{ contact.point_of_contact_for }} {{ contact.name }} + {{ contact.label_in_reference_list }} {% endfor %} @@ -130,7 +130,7 @@ {% for contact in poi_form.instance.contacts.all %} - {{ contact.point_of_contact_for }} {{ contact.name }} + {{ contact.label_in_reference_list }} {% endfor %} diff --git a/integreat_cms/cms/templates/pois/poi_form_sidebar/related_contacts_box.html b/integreat_cms/cms/templates/pois/poi_form_sidebar/related_contacts_box.html index cd8022ef9e..c4a7822d05 100644 --- a/integreat_cms/cms/templates/pois/poi_form_sidebar/related_contacts_box.html +++ b/integreat_cms/cms/templates/pois/poi_form_sidebar/related_contacts_box.html @@ -20,7 +20,7 @@ {% for contact in contacts %} - {{ contact }} + {{ contact.label_in_reference_list }} {% endfor %} diff --git a/integreat_cms/locale/de/LC_MESSAGES/django.po b/integreat_cms/locale/de/LC_MESSAGES/django.po index bc52cb5658..b4f84351d1 100644 --- a/integreat_cms/locale/de/LC_MESSAGES/django.po +++ b/integreat_cms/locale/de/LC_MESSAGES/django.po @@ -1640,9 +1640,9 @@ msgstr "Aktiv" msgid "Hidden" msgstr "Versteckt" -#: cms/constants/region_status.py cms/models/pages/page_translation.py -#: cms/models/regions/region.py cms/templates/events/event_form.html -#: cms/templates/pages/page_form.html +#: cms/constants/region_status.py cms/models/contact/contact.py +#: cms/models/pages/page_translation.py cms/models/regions/region.py +#: cms/templates/events/event_form.html cms/templates/pages/page_form.html #: cms/templates/pages/page_tree_archived_node.html #: cms/templates/pois/poi_form.html msgid "Archived" @@ -2777,6 +2777,10 @@ msgstr "mit Telefonnummer: {}" msgid "with website: {}" msgstr "mit Website: {}" +#: cms/models/contact/contact.py +msgid "General contact information" +msgstr "Allgemeine Kontaktinformationen" + #: cms/models/contact/contact.py msgid "(Copy)" msgstr "(Kopie)" @@ -11022,9 +11026,6 @@ msgstr "" "Diese Seite konnte nicht importiert werden, da sie zu einer anderen Region " "gehört ({})." -#~ msgid "General contact information" -#~ msgstr "Allgemeine Kontaktinformationen" - #~ msgid "{}{}" #~ msgstr "{}{}" diff --git a/tests/cms/views/poi/test_poi_form.py b/tests/cms/views/poi/test_poi_form.py index 717e02ad9f..c0e7bf6e4e 100644 --- a/tests/cms/views/poi/test_poi_form.py +++ b/tests/cms/views/poi/test_poi_form.py @@ -260,9 +260,10 @@ def test_poi_form_shows_associated_contacts( # probably needs adjustment after #2958 elif role in HIGH_PRIV_STAFF_ROLES: for contact in related_contacts: - if contact.title and contact.name: - assert f"{contact.title} {contact.name}" in response.content.decode( - "utf-8" + if contact.point_of_contact_for: + assert ( + f"{contact.point_of_contact_for} {contact.name}" + in response.content.decode("utf-8") ) else: assert "General contact information" in response.content.decode("utf-8")