From e6a985ddfa5aba93857ef2e3981927e99c93c4f3 Mon Sep 17 00:00:00 2001 From: moanos Date: Mon, 7 Apr 2025 21:30:14 +0200 Subject: [PATCH] feat: Add initial bulma version of adoption notice detail page --- .../fellchensammlung/base_bulma.html | 3 + .../fellchensammlung/bulma-styleguide.html | 16 +-- .../details/bulma-detail-adoption-notice.html | 125 ++++++++++++++++++ src/fellchensammlung/urls.py | 2 + src/fellchensammlung/views.py | 30 ++++- 5 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-adoption-notice.html diff --git a/src/fellchensammlung/templates/fellchensammlung/base_bulma.html b/src/fellchensammlung/templates/fellchensammlung/base_bulma.html index cf2003a..e5297cb 100644 --- a/src/fellchensammlung/templates/fellchensammlung/base_bulma.html +++ b/src/fellchensammlung/templates/fellchensammlung/base_bulma.html @@ -12,12 +12,15 @@ + + + diff --git a/src/fellchensammlung/templates/fellchensammlung/bulma-styleguide.html b/src/fellchensammlung/templates/fellchensammlung/bulma-styleguide.html index 37ee263..c0ea9e9 100644 --- a/src/fellchensammlung/templates/fellchensammlung/bulma-styleguide.html +++ b/src/fellchensammlung/templates/fellchensammlung/bulma-styleguide.html @@ -7,15 +7,15 @@ {% block content %}
+
+

+ Hello World +

+

+ Notfellchen bald mit Bulma? +

+
-
-

- Hello World -

-

- Notfellchen bald mit Bulma? -

-
diff --git a/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-adoption-notice.html b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-adoption-notice.html new file mode 100644 index 0000000..d6e50a9 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/details/bulma-detail-adoption-notice.html @@ -0,0 +1,125 @@ +{% extends "fellchensammlung/base_bulma.html" %} +{% load custom_tags %} +{% load i18n %} + +{% block title %}{{ adoption_notice.name }}{% endblock %} + +{% block content %} +
+
+

{{ adoption_notice.name }}

+
+
+
+
+ +
+
+

{% translate "Ort" %}

+

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

+
+ {% if adoption_notice.organization %} +
+

{% translate "Organisation" %}

+
+ {{ adoption_notice.organization }} + {% if adoption_notice.organization.trusted %} +
+ {% endif %} +
+
+ {% endif %} + +
+

{% translate "Suchen seit" %}

+

{{ adoption_notice.searching_since }}

+
+ +
+

{% translate "Zuletzt aktualisiert" %}

+

{{ adoption_notice.last_checked_hr }}

+
+ +
+

{% translate "Weitere Informationen" %}

+ {% if adoption_notice.further_information %} +
+ + +
+ {% else %} + - + {% endif %} +
+
+
+
+
+ +
+ +
+

{% translate "Bilder" %}

+
+ {% for photo in adoption_notice.get_photos %} + + {% endfor %} +
+
+ +
+
+
+

{% translate "Beschreibung" %}

+
+
+

{% if adoption_notice.description %} + {{ adoption_notice.description | render_markdown }} + {% else %} + {% translate "Keine Beschreibung angegeben" %} + {% endif %} +

+
+
+
+
+
r + +
+
+ {% for animal in adoption_notice.animals %} +
+ {% include "fellchensammlung/partials/partial-animal-card.html" %} +
+ {% endfor %} +
+ + {% include "fellchensammlung/partials/partial-comment-section.html" %} + +{% endblock %} diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index 0f95d2d..5dfb91d 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -18,6 +18,7 @@ sitemaps = { urlpatterns = [ path("", views.index, name="index"), + path("bulma/", views.index_bulma, name="index-bulma"), path("rss/", LatestAdoptionNoticesFeed(), name="rss"), path("metrics/", views.metrics, name="metrics"), # ex: /animal/5/ @@ -28,6 +29,7 @@ urlpatterns = [ path("tier//add-photo", views.add_photo_to_animal, name="animal-add-photo"), # 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"), # ex: /adoption_notice/7/edit path("vermittlung//edit", views.adoption_notice_edit, name="adoption-notice-edit"), # ex: /vermittlung/5/add-photo diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index ee63513..f9ae554 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -63,6 +63,22 @@ def index(request): return render(request, 'fellchensammlung/index.html', context=context) +def index_bulma(request): + """View function for home page of site.""" + latest_adoption_list = AdoptionNotice.objects.filter( + adoptionnoticestatus__major_status=AdoptionNoticeStatus.ACTIVE).order_by("-created_at") + active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active] + language_code = translation.get_language() + lang = Language.objects.get(languagecode=language_code) + active_announcements = Announcement.get_active_announcements(lang) + + context = {"adoption_notices": active_adoptions[:5], "adoption_notices_map": active_adoptions, + "announcements": active_announcements} + Text.get_texts(["how_to", "introduction"], lang, context) + + return render(request, 'fellchensammlung/bulma-index.html', context=context) + + def change_language(request): if request.method == 'POST': language_code = request.POST.get('language') @@ -82,7 +98,7 @@ def change_language(request): return render(request, 'fellchensammlung/index.html') -def adoption_notice_detail(request, adoption_notice_id): +def adoption_notice_detail(request, adoption_notice_id, template=None): adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id) if request.user.is_authenticated: try: @@ -139,7 +155,17 @@ def adoption_notice_detail(request, adoption_notice_id): comment_form = CommentForm(instance=adoption_notice) context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user, "has_edit_permission": has_edit_permission, "is_subscribed": is_subscribed} - return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context) + print(f"{template=}") + if template is not None: + return render(request, template, context=context) + else: + print("dada") + return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context) + + +def adoption_notice_detail_bulma(request, adoption_notice_id): + return adoption_notice_detail(request, adoption_notice_id, + template='fellchensammlung/details/bulma-detail-adoption-notice.html') @login_required()