From 75789f42471e3f5cbf8ba6293e5426366e6f1e42 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 7 Feb 2026 20:19:34 +0100 Subject: [PATCH] feat: Add instagram story photo generator --- .../images/adoption-notice-story.svg | 206 ++++++++++++++++++ src/fellchensammlung/tools/img.py | 4 +- src/fellchensammlung/urls.py | 3 + src/fellchensammlung/views.py | 6 + 4 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 src/fellchensammlung/templates/fellchensammlung/images/adoption-notice-story.svg diff --git a/src/fellchensammlung/templates/fellchensammlung/images/adoption-notice-story.svg b/src/fellchensammlung/templates/fellchensammlung/images/adoption-notice-story.svg new file mode 100644 index 0000000..7ee56ee --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/images/adoption-notice-story.svg @@ -0,0 +1,206 @@ + + + +notfellchen.org{{ adoption_notice.name }}{{ adoption_notice.location }}{{ adoption_notice.description }} diff --git a/src/fellchensammlung/tools/img.py b/src/fellchensammlung/tools/img.py index 455a188..df91dc8 100644 --- a/src/fellchensammlung/tools/img.py +++ b/src/fellchensammlung/tools/img.py @@ -3,7 +3,7 @@ from django.template.loader import render_to_string from fellchensammlung.models import AdoptionNotice -def export_svg(adoption_notice): - result = render_to_string(template_name="fellchensammlung/images/adoption-notice.svg", +def export_svg(adoption_notice, template_name: str = "fellchensammlung/images/adoption-notice.svg"): + result = render_to_string(template_name=template_name, context={"adoption_notice": adoption_notice, }) return result diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index 1b203af..2277d9f 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -33,6 +33,9 @@ urlpatterns = [ # ex: /adoption_notice/7/sharepic path("vermittlung//sharepic", views.adoption_notice_sharepic, name="adoption-notice-sharepic"), + # ex: /adoption_notice/7/story + path("vermittlung//storypic", views.adoption_notice_story_pic, + name="adoption-notice-story-pic"), # 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 c23b509..76240aa 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -1050,6 +1050,12 @@ def adoption_notice_sharepic(request, adoption_notice_id): return HttpResponse(svg_data, content_type="image/svg+xml") +def adoption_notice_story_pic(request, adoption_notice_id): + adoption_notice = get_object_or_404(AdoptionNotice, pk=adoption_notice_id) + svg_data = img.export_svg(adoption_notice, "fellchensammlung/images/adoption-notice-story.svg") + return HttpResponse(svg_data, content_type="image/svg+xml") + + @login_required def rescue_org_create_or_update(request, rescue_organization_id=None): """