From cf15b60beffa7e69e4deea05a4b9735105c995c9 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 22 May 2025 19:46:24 +0200 Subject: [PATCH] refactor(bulma): Add support for rescue organizations --- src/fellchensammlung/models.py | 5 ++ .../img/logo_transparent_small.png | Bin 0 -> 546 bytes .../bulma-animal-shelters.html | 15 ++++ .../bulma-detail-rescue-organization.html | 72 ++++++++++++++++++ .../lists/bulma-list-animal-shelters.html | 12 +++ .../partials/bulma-partial-map.html | 2 +- ...rtial-rescue-organization-minimal-map.html | 40 ++++++++++ .../bulma-partial-rescue-organization.html | 25 ++++++ src/fellchensammlung/urls.py | 6 +- src/fellchensammlung/views.py | 22 ++++-- 10 files changed, 192 insertions(+), 7 deletions(-) create mode 100644 src/fellchensammlung/static/fellchensammlung/img/logo_transparent_small.png create mode 100644 src/fellchensammlung/templates/fellchensammlung/bulma-animal-shelters.html create mode 100644 src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html create mode 100644 src/fellchensammlung/templates/fellchensammlung/lists/bulma-list-animal-shelters.html create mode 100644 src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-minimal-map.html create mode 100644 src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization.html diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index e4ffe02..1976732 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -156,6 +156,9 @@ class RescueOrganization(models.Model): def get_absolute_url(self): return reverse("rescue-organization-detail", args=[str(self.pk)]) + def get_absolute_url_bulma(self): + return reverse("bulma-rescue-organization-detail", args=[str(self.pk)]) + @property def adoption_notices(self): return AdoptionNotice.objects.filter(organization=self) @@ -173,6 +176,8 @@ class RescueOrganization(models.Model): return "" if len(self.description) > 200: return self.description[:200] + _(f" ... [weiterlesen]({self.get_absolute_url()})") + else: + return self.description def set_checked(self): self.last_checked = timezone.now() diff --git a/src/fellchensammlung/static/fellchensammlung/img/logo_transparent_small.png b/src/fellchensammlung/static/fellchensammlung/img/logo_transparent_small.png new file mode 100644 index 0000000000000000000000000000000000000000..b57c9e3d0a81c971e1b92dbdf4fc3571bf10947b GIT binary patch literal 546 zcmV+-0^R+IP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10k26! zK~y-6rPRxBO;HpE@Sl6@YKl^A8cLg@H6Rfr6^~9lVk9DBAQ2IU60`mR{tJu@C76hj z31QG#J8C@A1_L575d^oC8tiqFb5HI)uIo!q&OU3e_3eGW^{DC`7qJgZ_|VLu(jjpV zKI2v#&=g&55N*Rmte4~2j=N#2ql#aDBOk&M{Eh&a$DJU};|gvBX;bndF6GuovA4vx zH~g=*awuy4Gq-+(T_xn1=AYUn&wuww@|0l$*DzABZ)!%~kIPtx{dgSqUP;cSb*Z2u+>l=w_ZWjmf3R>b>) zRBnqU!DTpz^O(jrbmMsi$MEbwh^ta!w@SIGV*ztj9LB>Ai3fwMh5@X?SFFUlE{&bl zPN&u4rWO2tV--5T8lxlQ2_f)V`lC2+W!v0hm4Ttaq>!rS!&EIq+ zHb$`-_oXrV5nsZm9*4e`nyZGF*bp-G;hw_$$*N@%V|Wk&uR@+doWu*vVK=@@1+b)X kT>LYJB+10#u(93XKRHrV(X_O5Jpcdz07*qoM6N<$f>m<$)&Kwi literal 0 HcmV?d00001 diff --git a/src/fellchensammlung/templates/fellchensammlung/bulma-animal-shelters.html b/src/fellchensammlung/templates/fellchensammlung/bulma-animal-shelters.html new file mode 100644 index 0000000..47e6f75 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/bulma-animal-shelters.html @@ -0,0 +1,15 @@ +{% extends "fellchensammlung/base_bulma.html" %} +{% load i18n %} + +{% block title %}{% translate "Tierschutzorganisationen" %}{% endblock %} + +{% block content %} +
+
+ {% include "fellchensammlung/partials/bulma-partial-map.html" %} +
+
+
+ {% include "fellchensammlung/lists/bulma-list-animal-shelters.html" %} +
+{% endblock %} diff --git a/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html new file mode 100644 index 0000000..0ce15eb --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-rescue-organization.html @@ -0,0 +1,72 @@ +{% extends "fellchensammlung/base_bulma.html" %} +{% load custom_tags %} +{% load i18n %} + +{% block title %}{{ org.name }}{% endblock %} + +{% block content %} +
+
+
+
+

{{ org.name }}

+
+
+
+ + {% if org.location %} + {{ org.location }} + {% else %} + {{ org.location_string }} + {% endif %} + {% if org.description %} +

{{ 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-map.html" %} +
+
+ + +

{% translate 'Vermittlungen der Organisation' %}

+
+ {% if org.adoption_notices %} + {% for adoption_notice in org.adoption_notices %} + {% include "fellchensammlung/partials/bulma-partial-adoption-notice-minimal.html" %} + {% endfor %} + {% else %} +

{% translate "Keine Vermittlungen gefunden." %}

+ {% endif %} +
+{% endblock %} diff --git a/src/fellchensammlung/templates/fellchensammlung/lists/bulma-list-animal-shelters.html b/src/fellchensammlung/templates/fellchensammlung/lists/bulma-list-animal-shelters.html new file mode 100644 index 0000000..3c5217b --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/lists/bulma-list-animal-shelters.html @@ -0,0 +1,12 @@ +{% load i18n %} +
+ {% if rescue_organizations %} + {% for rescue_organization in rescue_organizations %} +
+ {% include "fellchensammlung/partials/bulma-partial-rescue-organization.html" %} +
+ {% endfor %} + {% else %} +

{% translate "Keine Tierschutzorganisationen gefunden." %}

+ {% endif %} +
diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-map.html b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-map.html index a2eb0ad..cb94852 100644 --- a/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-map.html +++ b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-map.html @@ -59,7 +59,7 @@ {% for rescue_organization in rescue_organizations %} {% if rescue_organization.location %} // create the popup - const popup_{{ forloop.counter }} = new maplibregl.Popup({offset: 25}).setHTML(`{% include "fellchensammlung/partials/partial-rescue-organization.html" %}`); + const popup_{{ forloop.counter }} = new maplibregl.Popup({offset: 25}).setHTML(`{% include "fellchensammlung/partials/bulma-partial-rescue-organization-minimal-map.html" %}`); // create DOM element for the marker const el_{{ forloop.counter }} = document.createElement('div'); diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-minimal-map.html b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-minimal-map.html new file mode 100644 index 0000000..67dc8fe --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization-minimal-map.html @@ -0,0 +1,40 @@ +{% load custom_tags %} +{% load i18n %} + +{% load custom_tags %} +{% load i18n %} + + +

+ {{ rescue_organization.name }} +

+ +
+
+ +
+ +
+ +

+ + {% if rescue_organization.location %} + {{ rescue_organization.location }} + {% else %} + {{ rescue_organization.location_string }} + {% endif %}

+
+
+
+
+ +{% if rescue_organization.description_short %} +
+ {{ rescue_organization.description_short | render_markdown }} + +
+{% endif %} + + + + diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization.html b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization.html new file mode 100644 index 0000000..d807286 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/partials/bulma-partial-rescue-organization.html @@ -0,0 +1,25 @@ +{% load custom_tags %} +{% load i18n %} + +
+ +
+

+ + {% if rescue_organization.location %} + {{ rescue_organization.location.str_hr }} + {% else %} + {{ rescue_organization.location_string }} + {% endif %} +

+

+ {% if rescue_organization.description_short %} + {{ rescue_organization.description_short | render_markdown }} + {% endif %} +

+
+
\ No newline at end of file diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index 41b968b..c32f08d 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -30,7 +30,8 @@ urlpatterns = [ path("bulma/tier//add-photo", views.add_photo_to_animal_bulma, name="animal-add-photo-bulma"), # ex: /adoption_notice/7/ path("vermittlung//", views.adoption_notice_detail, name="adoption-notice-detail"), - path("bulma/vermittlung//", views.adoption_notice_detail_bulma, name="adoption-notice-detail-bulma"), + path("bulma/vermittlung//", views.adoption_notice_detail_bulma, + name="adoption-notice-detail-bulma"), # ex: /adoption_notice/7/edit path("vermittlung//edit", views.adoption_notice_edit, name="adoption-notice-edit"), # ex: /vermittlung/5/add-photo @@ -43,8 +44,11 @@ urlpatterns = [ name="adoption-notice-add-animal"), path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"), + path("bulma/tierschutzorganisationen/", views.bulma_list_rescue_organizations, name="bulma-rescue-organizations"), path("organisation//", views.detail_view_rescue_organization, name="rescue-organization-detail"), + path("bulma/organisation//", views.bulma_detail_view_rescue_organization, + name="bulma-rescue-organization-detail"), # ex: /search/ path("suchen/", views.search, name="search"), diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index b447df7..319e139 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -408,6 +408,7 @@ def add_photo_to_animal(request, animal_id): form = ImageForm(in_flow=True) return render(request, 'fellchensammlung/forms/form-image.html', {'form': form}) + @login_required def add_photo_to_animal_bulma(request, animal_id): animal = Animal.objects.get(id=animal_id) @@ -440,7 +441,6 @@ def add_photo_to_animal_bulma(request, animal_id): return render(request, 'fellchensammlung/forms/bulma-form-image.html', {'form': form}) - @login_required def add_photo_to_adoption_notice(request, adoption_notice_id): adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id) @@ -468,6 +468,7 @@ def add_photo_to_adoption_notice(request, adoption_notice_id): form = ImageForm(in_flow=True) return render(request, 'fellchensammlung/forms/form-image.html', {'form': form}) + @login_required def add_photo_to_adoption_notice_bulma(request, adoption_notice_id): adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id) @@ -808,18 +809,29 @@ def external_site_warning(request): return render(request, 'fellchensammlung/external_site_warning.html', context=context) -def list_rescue_organizations(request): +def list_rescue_organizations(request, template='fellchensammlung/animal-shelters.html'): rescue_organizations = RescueOrganization.objects.all() context = {"rescue_organizations": rescue_organizations} - return render(request, 'fellchensammlung/animal-shelters.html', context=context) + return render(request, template, context=context) -def detail_view_rescue_organization(request, rescue_organization_id): +def bulma_list_rescue_organizations(request): + return list_rescue_organizations(request, template='fellchensammlung/bulma-animal-shelters.html') + + +def detail_view_rescue_organization(request, rescue_organization_id, + template='fellchensammlung/details/detail-rescue-organization.html'): org = RescueOrganization.objects.get(pk=rescue_organization_id) - return render(request, 'fellchensammlung/details/detail-rescue-organization.html', + return render(request, template, context={"org": org, "map_center": org.position, "zoom_level": 6, "rescue_organizations": [org]}) +def bulma_detail_view_rescue_organization(request, rescue_organization_id): + return detail_view_rescue_organization(request, + rescue_organization_id, + template='fellchensammlung/details/bulma-detail-rescue-organization.html') + + def export_own_profile(request): user = request.user ANs = AdoptionNotice.objects.filter(owner=user)