feat: Add domain customtag
This commit is contained in:
		@@ -48,7 +48,14 @@
 | 
				
			|||||||
                <td>{{ adoption_notice.searching_since }}</td>
 | 
					                <td>{{ adoption_notice.searching_since }}</td>
 | 
				
			||||||
                <td>{{ adoption_notice.last_checked | date:'d. F Y' }}</td>
 | 
					                <td>{{ adoption_notice.last_checked | date:'d. F Y' }}</td>
 | 
				
			||||||
                {% if adoption_notice.further_information %}
 | 
					                {% if adoption_notice.further_information %}
 | 
				
			||||||
                    <td>{{ adoption_notice.link_to_more_information | safe }}</td>
 | 
					                    <td>
 | 
				
			||||||
 | 
					                        <form method="get" action="{% url 'external-site' %}">
 | 
				
			||||||
 | 
					                            <input type="hidden" name="url" value="adoption_notice.further_information">
 | 
				
			||||||
 | 
					                            <button class="btn" type="submit" id="submit">
 | 
				
			||||||
 | 
					                                 {{ adoption_notice.further_information | domain }} <i class="fa-solid fa-arrow-up-right-from-square"></i>
 | 
				
			||||||
 | 
					                            </button>
 | 
				
			||||||
 | 
					                        </form>
 | 
				
			||||||
 | 
					                    </td>
 | 
				
			||||||
                {% else %}
 | 
					                {% else %}
 | 
				
			||||||
                    <td>-</td>
 | 
					                    <td>-</td>
 | 
				
			||||||
                {% endif %}
 | 
					                {% endif %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ from django import template
 | 
				
			|||||||
from django.template.defaultfilters import stringfilter
 | 
					from django.template.defaultfilters import stringfilter
 | 
				
			||||||
from django.utils.safestring import mark_safe
 | 
					from django.utils.safestring import mark_safe
 | 
				
			||||||
from notfellchen import settings
 | 
					from notfellchen import settings
 | 
				
			||||||
 | 
					from urllib.parse import urlparse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
register = template.Library()
 | 
					register = template.Library()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -56,6 +57,17 @@ def pointdecimal(value):
 | 
				
			|||||||
    except ValueError:
 | 
					    except ValueError:
 | 
				
			||||||
        return value
 | 
					        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
 | 
					@register.simple_tag
 | 
				
			||||||
def settings_value(name):
 | 
					def settings_value(name):
 | 
				
			||||||
    return getattr(settings, name)
 | 
					    return getattr(settings, name)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user