From e3833b4505cdee0723b0490f625e64f7118766b6 Mon Sep 17 00:00:00 2001 From: moanos Date: Mon, 6 Jan 2025 08:36:51 +0100 Subject: [PATCH] feat: Show position of shelter on the map --- src/fellchensammlung/models.py | 10 ++- .../details/detail-rescue-organization.html | 88 ++++++++++--------- .../partials/partial-map.html | 33 ++++++- src/fellchensammlung/views.py | 3 +- 4 files changed, 90 insertions(+), 44 deletions(-) diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index b935472..b017a81 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -13,7 +13,7 @@ from django.contrib.auth.models import AbstractUser from .tools import misc, geo from notfellchen.settings import MEDIA_URL -from .tools.geo import LocationProxy +from .tools.geo import LocationProxy, Position from .tools.misc import age_as_hr_string, time_since_as_hr_string @@ -134,6 +134,14 @@ class RescueOrganization(models.Model): def adoption_notices(self): return AdoptionNotice.objects.filter(organization=self) + @property + def position(self): + if self.location: + return Position(latitude=self.location.latitude, longitude=self.location.longitude) + else: + return None + + # 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/detail-rescue-organization.html b/src/fellchensammlung/templates/fellchensammlung/details/detail-rescue-organization.html index 066bd5a..0d1037c 100644 --- a/src/fellchensammlung/templates/fellchensammlung/details/detail-rescue-organization.html +++ b/src/fellchensammlung/templates/fellchensammlung/details/detail-rescue-organization.html @@ -5,51 +5,57 @@ {% block title %}{{ org.name }}{% endblock %} {% block content %} -
-

{{ org.name }}

+
+
+

{{ org.name }}

- - {% if org.location %} - {{ org.location.str_hr }} - {% else %} - {{ org.location_string }} - {% endif %} -

{{ org.description | render_markdown }}

- - - - {% if org.website %} - - {% endif %} - {% if org.phone_number %} - - {% endif %} - {% if org.email %} - - {% endif %} - - - - {% if org.website %} - - {% endif %} - {% if org.phone_number %} - - {% endif %} + + {% if org.location %} + {{ org.location.str_hr }} + {% else %} + {{ org.location_string }} + {% endif %} +

{{ org.description | render_markdown }}

+
{% translate "Website" %}{% translate "Telefonnummer" %}{% translate "E-Mail" %}
- {{ org.website }} - - {{ org.phone_number }} -
+ + + {% if org.website %} + + {% endif %} + {% if org.phone_number %} + + {% endif %} + {% if org.email %} + + {% endif %} + + + + {% if org.website %} + + {% endif %} + {% if org.phone_number %} + + {% endif %} - {% if org.email %} - - {% endif %} - -
{% translate "Website" %}{% translate "Telefonnummer" %}{% translate "E-Mail" %}
+ {{ org.website }} + + {{ org.phone_number }} + - {{ org.email }} -
+ {% if org.email %} + + {{ org.email }} + + {% endif %} + + +
+
+ {% include "fellchensammlung/partials/partial-map.html" %} +
+

{% translate 'Vermittlungen der Organisation' %}

{% if org.adoption_notices %} diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/partial-map.html b/src/fellchensammlung/templates/fellchensammlung/partials/partial-map.html index d9381c8..bd04728 100644 --- a/src/fellchensammlung/templates/fellchensammlung/partials/partial-map.html +++ b/src/fellchensammlung/templates/fellchensammlung/partials/partial-map.html @@ -15,7 +15,7 @@