feat: Show position of shelter on the map
This commit is contained in:
parent
ab837ee80e
commit
e3833b4505
@ -13,7 +13,7 @@ from django.contrib.auth.models import AbstractUser
|
|||||||
|
|
||||||
from .tools import misc, geo
|
from .tools import misc, geo
|
||||||
from notfellchen.settings import MEDIA_URL
|
from notfellchen.settings import MEDIA_URL
|
||||||
from .tools.geo import LocationProxy
|
from .tools.geo import LocationProxy, Position
|
||||||
from .tools.misc import age_as_hr_string, time_since_as_hr_string
|
from .tools.misc import age_as_hr_string, time_since_as_hr_string
|
||||||
|
|
||||||
|
|
||||||
@ -134,6 +134,14 @@ class RescueOrganization(models.Model):
|
|||||||
def adoption_notices(self):
|
def adoption_notices(self):
|
||||||
return AdoptionNotice.objects.filter(organization=self)
|
return AdoptionNotice.objects.filter(organization=self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def position(self):
|
||||||
|
if self.location:
|
||||||
|
return Position(latitude=self.location.latitude, longitude=self.location.longitude)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Admins can perform all actions and have the highest trust associated with them
|
# Admins can perform all actions and have the highest trust associated with them
|
||||||
# Moderators can make moderation decisions regarding the deletion of content
|
# Moderators can make moderation decisions regarding the deletion of content
|
||||||
|
@ -5,51 +5,57 @@
|
|||||||
{% block title %}<title>{{ org.name }}</title>{% endblock %}
|
{% block title %}<title>{{ org.name }}</title>{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="card">
|
<div class="container-cards">
|
||||||
<h1>{{ org.name }}</h1>
|
<div class="card half">
|
||||||
|
<h1>{{ org.name }}</h1>
|
||||||
|
|
||||||
<b><i class="fa-solid fa-location-dot"></i></b>
|
<b><i class="fa-solid fa-location-dot"></i></b>
|
||||||
{% if org.location %}
|
{% if org.location %}
|
||||||
{{ org.location.str_hr }}
|
{{ org.location.str_hr }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ org.location_string }}
|
{{ org.location_string }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>{{ org.description | render_markdown }}</p>
|
<p>{{ org.description | render_markdown }}</p>
|
||||||
<table class="responsive">
|
<table class="responsive">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
{% if org.website %}
|
{% if org.website %}
|
||||||
<td>{% translate "Website" %}</td>
|
<td>{% translate "Website" %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if org.phone_number %}
|
{% if org.phone_number %}
|
||||||
<td>{% translate "Telefonnummer" %}</td>
|
<td>{% translate "Telefonnummer" %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if org.email %}
|
{% if org.email %}
|
||||||
<td>{% translate "E-Mail" %}</td>
|
<td>{% translate "E-Mail" %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr>
|
<tr>
|
||||||
{% if org.website %}
|
{% if org.website %}
|
||||||
<td data-label="{% trans 'Website' %} ">
|
<td data-label="{% trans 'Website' %} ">
|
||||||
{{ org.website }}
|
{{ org.website }}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if org.phone_number %}
|
{% if org.phone_number %}
|
||||||
<td data-label="{% trans 'Telefonnummer' %}">
|
<td data-label="{% trans 'Telefonnummer' %}">
|
||||||
{{ org.phone_number }}
|
{{ org.phone_number }}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if org.email %}
|
{% if org.email %}
|
||||||
<td data-label="{% trans 'E-Mail' %}">
|
<td data-label="{% trans 'E-Mail' %}">
|
||||||
{{ org.email }}
|
{{ org.email }}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="card half">
|
||||||
|
{% include "fellchensammlung/partials/partial-map.html" %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<h2>{% translate 'Vermittlungen der Organisation' %}</h2>
|
<h2>{% translate 'Vermittlungen der Organisation' %}</h2>
|
||||||
<div class="container-cards">
|
<div class="container-cards">
|
||||||
{% if org.adoption_notices %}
|
{% if org.adoption_notices %}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<!-- start map -->
|
<!-- start map -->
|
||||||
<script>
|
<script>
|
||||||
{% if map_center %}
|
{% if map_center %}
|
||||||
var center = [{{ map_center.longitude }}, {{ map_center.latitude }}];
|
var center = [parseFloat({{ map_center.longitude }}), parseFloat({{ map_center.latitude }})];
|
||||||
{% else %}
|
{% else %}
|
||||||
var center = [10.49, 50.68];
|
var center = [10.49, 50.68];
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -52,6 +52,37 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% 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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% if search_radius %}
|
{% if search_radius %}
|
||||||
map.on('load', () => {
|
map.on('load', () => {
|
||||||
const radius = {{ search_radius }}; // kilometer
|
const radius = {{ search_radius }}; // kilometer
|
||||||
|
@ -608,7 +608,8 @@ def external_site_warning(request):
|
|||||||
|
|
||||||
def detail_view_rescue_organization(request, rescue_organization_id):
|
def detail_view_rescue_organization(request, rescue_organization_id):
|
||||||
org = RescueOrganization.objects.get(pk=rescue_organization_id)
|
org = RescueOrganization.objects.get(pk=rescue_organization_id)
|
||||||
return render(request, 'fellchensammlung/details/detail-rescue-organization.html', context={"org": org})
|
return render(request, 'fellchensammlung/details/detail-rescue-organization.html',
|
||||||
|
context={"org": org, "map_center": org.position, "zoom_level": 6, "map_pins": [org.position]})
|
||||||
|
|
||||||
|
|
||||||
def export_own_profile(request):
|
def export_own_profile(request):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user