refactor(bulma): Add support for rescue organizations

This commit is contained in:
2025-05-22 19:46:24 +02:00
parent 328f64aa51
commit cf15b60bef
10 changed files with 192 additions and 7 deletions

View File

@@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

View File

@@ -0,0 +1,15 @@
{% extends "fellchensammlung/base_bulma.html" %}
{% load i18n %}
{% block title %}<title>{% translate "Tierschutzorganisationen" %}</title>{% endblock %}
{% block content %}
<div class="block">
<div style="height: 70vh">
{% include "fellchensammlung/partials/bulma-partial-map.html" %}
</div>
</div>
<div class="block">
{% include "fellchensammlung/lists/bulma-list-animal-shelters.html" %}
</div>
{% endblock %}

View File

@@ -0,0 +1,72 @@
{% extends "fellchensammlung/base_bulma.html" %}
{% load custom_tags %}
{% load i18n %}
{% block title %}<title>{{ org.name }}</title>{% endblock %}
{% block content %}
<div class="columns">
<div class="column">
<div class="card">
<div class="card-header">
<h1 class="card-header-title">{{ org.name }}</h1>
</div>
<div class="card-content">
<div class="block">
<b><i class="fa-solid fa-location-dot"></i></b>
{% if org.location %}
{{ org.location }}
{% else %}
{{ org.location_string }}
{% endif %}
{% if org.description %}
<p>{{ org.description | render_markdown }}</p>
{% endif %}
</div>
<div class="panel block">
<p class="panel-heading">{% trans "Kontaktdaten" %}</p>
{% if org.website %}
<a class="panel-block is-active">
<span class="panel-icon">
<i class="fas fa-globe" aria-label="{% translate "Website" %}"></i>
</span>
{{ org.website }}
</a>
{% endif %}
{% if org.phone_number %}
<a class="panel-block is-active">
<span class="panel-icon">
<i class="fas fa-phone" aria-label="{% translate "Telefonnummer" %}"></i>
</span>
{{ org.phone_number }}
</a>
{% endif %}
{% if org.email %}
<a class="panel-block is-active">
<span class="panel-icon">
<i class="fas fa-envelope" aria-label="{% translate "E-Mail" %}"></i>
</span>
{{ org.email }}
</a>
{% endif %}
</div>
</div>
</div>
</div>
<div class="column">
{% include "fellchensammlung/partials/bulma-partial-map.html" %}
</div>
</div>
<h2>{% translate 'Vermittlungen der Organisation' %}</h2>
<div class="container-cards">
{% if org.adoption_notices %}
{% for adoption_notice in org.adoption_notices %}
{% include "fellchensammlung/partials/bulma-partial-adoption-notice-minimal.html" %}
{% endfor %}
{% else %}
<p>{% translate "Keine Vermittlungen gefunden." %}</p>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% load i18n %}
<div class="grid is-col-min-10">
{% if rescue_organizations %}
{% for rescue_organization in rescue_organizations %}
<div class="cell">
{% include "fellchensammlung/partials/bulma-partial-rescue-organization.html" %}
</div>
{% endfor %}
{% else %}
<p>{% translate "Keine Tierschutzorganisationen gefunden." %}</p>
{% endif %}
</div>

View File

@@ -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');

View File

@@ -0,0 +1,40 @@
{% load custom_tags %}
{% load i18n %}
{% load custom_tags %}
{% load i18n %}
<h2 class="title is-4">
<a href="{{ rescue_organization.get_absolute_url_bulma }}"> {{ rescue_organization.name }}</a>
</h2>
<div class="grid mb-0">
<div class="cell">
<!--- General Information --->
<div class="grid">
<div class="cell">
<p>
<b><i class="fa-solid fa-location-dot"></i></b>
{% if rescue_organization.location %}
{{ rescue_organization.location }}
{% else %}
{{ rescue_organization.location_string }}
{% endif %}</p>
</div>
</div>
</div>
</div>
{% if rescue_organization.description_short %}
<div class="content">
{{ rescue_organization.description_short | render_markdown }}
</div>
{% endif %}

View File

@@ -0,0 +1,25 @@
{% load custom_tags %}
{% load i18n %}
<div class="card">
<div class="card-header">
<h2 class="card-header-title"><a
href="{{ rescue_organization.get_absolute_url_bulma }}"> {{ rescue_organization.name }}</a></h2>
</div>
<div class="card-content">
<p>
<b><i class="fa-solid fa-location-dot"></i></b>
{% if rescue_organization.location %}
{{ rescue_organization.location.str_hr }}
{% else %}
{{ rescue_organization.location_string }}
{% endif %}
</p>
<p>
{% if rescue_organization.description_short %}
{{ rescue_organization.description_short | render_markdown }}
{% endif %}
</p>
</div>
</div>

View File

@@ -30,7 +30,8 @@ urlpatterns = [
path("bulma/tier/<int:animal_id>/add-photo", views.add_photo_to_animal_bulma, name="animal-add-photo-bulma"),
# ex: /adoption_notice/7/
path("vermittlung/<int:adoption_notice_id>/", views.adoption_notice_detail, name="adoption-notice-detail"),
path("bulma/vermittlung/<int:adoption_notice_id>/", views.adoption_notice_detail_bulma, name="adoption-notice-detail-bulma"),
path("bulma/vermittlung/<int:adoption_notice_id>/", views.adoption_notice_detail_bulma,
name="adoption-notice-detail-bulma"),
# ex: /adoption_notice/7/edit
path("vermittlung/<int:adoption_notice_id>/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/<int:rescue_organization_id>/", views.detail_view_rescue_organization,
name="rescue-organization-detail"),
path("bulma/organisation/<int:rescue_organization_id>/", views.bulma_detail_view_rescue_organization,
name="bulma-rescue-organization-detail"),
# ex: /search/
path("suchen/", views.search, name="search"),

View File

@@ -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)