From 864c76bc2153e75111bf9c3451fe1b0ed71210a1 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 5 Oct 2024 11:05:33 +0200 Subject: [PATCH] feat: Add domain customtag --- .../details/detail_adoption_notice.html | 9 ++++++++- src/fellchensammlung/templatetags/custom_tags.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html b/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html index 58a175f..e90b8b3 100644 --- a/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html +++ b/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html @@ -48,7 +48,14 @@ {{ adoption_notice.searching_since }} {{ adoption_notice.last_checked | date:'d. F Y' }} {% if adoption_notice.further_information %} - {{ adoption_notice.link_to_more_information | safe }} + +
+ + +
+ {% else %} - {% endif %} diff --git a/src/fellchensammlung/templatetags/custom_tags.py b/src/fellchensammlung/templatetags/custom_tags.py index 69740db..ae04582 100644 --- a/src/fellchensammlung/templatetags/custom_tags.py +++ b/src/fellchensammlung/templatetags/custom_tags.py @@ -4,6 +4,7 @@ from django import template from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe from notfellchen import settings +from urllib.parse import urlparse register = template.Library() @@ -56,6 +57,17 @@ def pointdecimal(value): except ValueError: return value +@register.filter +@stringfilter +def domain(url): + try: + domain = urlparse(url).netloc + if domain.startswith("www."): + return domain[4:] + return domain + except ValueError: + return url + @register.simple_tag def settings_value(name): return getattr(settings, name)