From 3c60782ae76211a88f0e14d610b4d607fa774b3c Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 25 May 2025 11:04:18 +0200 Subject: [PATCH] refactor(bulma): move contact details to partial --- src/fellchensammlung/models.py | 8 +++ .../bulma-detail-rescue-organization.html | 28 +-------- ...a-partial-rescue-organization-contact.html | 60 +++++++++++++++++++ 3 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-contact.html diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index cf3803f..1dae66e 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -198,6 +198,14 @@ class RescueOrganization(models.Model): def species_urls(self): return SpeciesSpecificURL.objects.filter(organization=self) + @property + def has_contact_data(self): + """ + Returns true if at least one type of contact data is available. + """ + return self.instagram or self.facebook or self.website or self.phone_number or self.email or self.fediverse_profile + + # Admins can perform all actions and have the highest trust associated with them # Moderators can make moderation decisions regarding the deletion of content diff --git a/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html index 0ce15eb..b394805 100644 --- a/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html +++ b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html @@ -23,34 +23,8 @@

{{ org.description | render_markdown }}

{% endif %} -
-

{% trans "Kontaktdaten" %}

- {% if org.website %} - - - - - {{ org.website }} - - {% endif %} - {% if org.phone_number %} - - - - - {{ org.phone_number }} - - {% endif %} - {% if org.email %} - - - - - {{ org.email }} - - {% endif %} -
+ {% include "fellchensammlung/partials/bulma-partial-rescue-organization-contact.html" %}
diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-contact.html b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-contact.html new file mode 100644 index 0000000..a911054 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-contact.html @@ -0,0 +1,60 @@ +{% load custom_tags %} +{% load i18n %} + +
+

{% trans "Kontaktdaten" %}

+ {% if org.hast_contact_data %} + {% if org.website %} + + + + + {{ org.website }} + + {% endif %} + {% if org.phone_number %} + + + + + {{ org.phone_number }} + + {% endif %} + {% if org.email %} + + + + + {{ org.email }} + + {% endif %} + + {% if org.fediverse_profile %} + + + + + {{ org.fediverse_profile }} + + {% endif %} + {% if org.instagram %} + + + + + {{ org.instagram }} + + {% endif %} + + {% if org.facebook %} + + + + + {{ org.facebook }} + + {% endif %} + {% else %} +

{% translate 'Keine Kontaktdaten hinterlegt' %}

+ {% endif %} +
\ No newline at end of file