feat: Add overview page of animal shelters

This commit is contained in:
moanos [he/him] 2025-01-06 09:02:07 +01:00
parent e3833b4505
commit 5e80d75c91
8 changed files with 81 additions and 30 deletions

View File

@ -140,6 +140,12 @@ class RescueOrganization(models.Model):
return Position(latitude=self.location.latitude, longitude=self.location.longitude)
else:
return None
@property
def description_short(self):
if self.description is None:
return ""
if len(self.description) > 200:
return self.description[:200] + f" ... [weiterlesen]({self.get_absolute_url()})"

View File

@ -937,6 +937,10 @@ div.announcement {
cursor: pointer;
}
.animal-shelter-marker {
background-image: url('../img/animal_shelter.png'); !important;
}
.maplibregl-popup {
max-width: 600px !important;
}

View File

@ -0,0 +1,13 @@
{% extends "fellchensammlung/base_generic.html" %}
{% load i18n %}
{% block title %}<title>{% translate "Tierschutzorganisationen" %}</title>{% endblock %}
{% block content %}
<div class="container-cards">
<div class="card">
{% include "fellchensammlung/partials/partial-map.html" %}
</div>
</div>
{% include "fellchensammlung/lists/list-animal-shelters.html" %}
{% endblock %}

View File

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

View File

@ -52,35 +52,23 @@
{% endif %}
{% endfor %}
{% for map_pin in map_pins %}
map.on('load', async () => {
image = await map.loadImage("{% static 'fellchensammlung/img/animal_shelter.png' %}");
map.addImage('cat', image.data);
map.addSource('point', {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [parseFloat({{ map_pin.longitude }}), parseFloat({{ map_pin.latitude }})]
}
}
]
}
});
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': 'point',
'layout': {
'icon-image': 'cat',
'icon-size': 0.25
}
});
});
{% for rescue_orgnization in rescue_organizations %}
{% if rescue_orgnization.location %}
// create the popup
const popup_{{ forloop.counter }} = new maplibregl.Popup({offset: 25}).setHTML(`{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}`);
// create DOM element for the marker
const el_{{ forloop.counter }} = document.createElement('div');
el_{{ forloop.counter }}.id = 'marker_{{ forloop.counter }}';
el_{{ forloop.counter }}.classList.add('animal-shelter-marker', 'marker');
const location_popup_{{ forloop.counter }} = [{{ rescue_orgnization.location.longitude | pointdecimal }}, {{ rescue_orgnization.location.latitude | pointdecimal }}];
// create the marker
new maplibregl.Marker({element: el_{{ forloop.counter }}})
.setLngLat(location_popup_{{ forloop.counter }})
.setPopup(popup_{{ forloop.counter }}) // sets a popup on this marker
.addTo(map);
{% endif %}
{% endfor %}
{% if search_radius %}

View File

@ -0,0 +1,24 @@
{% load custom_tags %}
{% load i18n %}
<div class="card">
<div>
<div class="header-card-adoption-notice">
<h2 class="heading-card-adoption-notice"><a
href="{{ rescue_organization.get_absolute_url }}"> {{ rescue_organization.name }}</a></h2>
</div>
<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

@ -25,6 +25,8 @@ urlpatterns = [
path("vermittlung/<int:adoption_notice_id>/add-photo", views.add_photo_to_adoption_notice, name="adoption-notice-add-photo"),
# ex: /adoption_notice/2/add-animal
path("vermittlung/<int:adoption_notice_id>/add-animal", views.adoption_notice_add_animal, name="adoption-notice-add-animal"),
path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"),
path("organisation/<int:rescue_organization_id>/", views.detail_view_rescue_organization,
name="rescue-organization-detail"),

View File

@ -605,11 +605,15 @@ def external_site_warning(request):
return render(request, 'fellchensammlung/external_site_warning.html', context=context)
def list_rescue_organizations(request):
rescue_organizations = RescueOrganization.objects.all()
context = {"rescue_organizations": rescue_organizations}
return render(request, 'fellchensammlung/animal-shelters.html', context=context)
def detail_view_rescue_organization(request, rescue_organization_id):
org = RescueOrganization.objects.get(pk=rescue_organization_id)
return render(request, 'fellchensammlung/details/detail-rescue-organization.html',
context={"org": org, "map_center": org.position, "zoom_level": 6, "map_pins": [org.position]})
context={"org": org, "map_center": org.position, "zoom_level": 6, "rescue_organizations": [org]})
def export_own_profile(request):