fix: Only show rescue orgs and animal shelters when relevant
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
|
|
||||||
map.on('load', async () => {
|
map.on('load', async () => {
|
||||||
|
{% if show_ANs %}
|
||||||
// Load adoption notices as geojson
|
// Load adoption notices as geojson
|
||||||
map.addSource('adoption-notices', {
|
map.addSource('adoption-notices', {
|
||||||
type: 'geojson',
|
type: 'geojson',
|
||||||
@@ -106,6 +106,79 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// inspect an AN cluster on click
|
||||||
|
map.on('click', 'clusters', async (e) => {
|
||||||
|
const features = map.queryRenderedFeatures(e.point, {
|
||||||
|
layers: ['clusters']
|
||||||
|
});
|
||||||
|
const clusterId = features[0].properties.cluster_id;
|
||||||
|
const zoom = await map.getSource('adoption-notices').getClusterExpansionZoom(clusterId);
|
||||||
|
map.easeTo({
|
||||||
|
center: features[0].geometry.coordinates,
|
||||||
|
zoom
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// When a click event occurs on a feature in
|
||||||
|
// the unclustered-point layer, open a popup at
|
||||||
|
// the location of the feature, with
|
||||||
|
// description HTML from its properties.
|
||||||
|
map.on('click', 'unclustered-point', (e) => {
|
||||||
|
const coordinates = e.features[0].geometry.coordinates.slice();
|
||||||
|
const title = e.features[0].properties.title;
|
||||||
|
const url = e.features[0].properties.url;
|
||||||
|
const description = e.features[0].properties.description;
|
||||||
|
const location_hr = e.features[0].properties.location_hr;
|
||||||
|
const image_url = e.features[0].properties.image_url;
|
||||||
|
const image_alt = e.features[0].properties.image_alt;
|
||||||
|
|
||||||
|
// Ensure that if the map is zoomed out such that
|
||||||
|
// multiple copies of the feature are visible, the
|
||||||
|
// popup appears over the copy being pointed to.
|
||||||
|
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
|
||||||
|
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
|
||||||
|
}
|
||||||
|
|
||||||
|
const description_column = `
|
||||||
|
<div class="column">
|
||||||
|
<strong><a class="is-size-7" href="${url}">${title}</a></strong> <i class="fa-solid fa-arrow-up-right-from-square"></i><br>
|
||||||
|
<span><strong>{% translate 'Ort' %}</strong>: ${location_hr}</span><br>
|
||||||
|
<p class="is-size-7">${truncate(description, 80, url)}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
let picture_column = '';
|
||||||
|
if (image_url) {
|
||||||
|
picture_column = `
|
||||||
|
<div class="column">
|
||||||
|
<figure class="image is-128x128">
|
||||||
|
<img src="${image_url}" alt="${image_alt}"/>
|
||||||
|
</figure>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
new maplibregl.Popup()
|
||||||
|
.setLngLat(coordinates)
|
||||||
|
.setHTML(`
|
||||||
|
<div class="popup-content is-size-7">
|
||||||
|
<div class="columns">
|
||||||
|
${description_column}
|
||||||
|
${picture_column}
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
)
|
||||||
|
.addTo(map);
|
||||||
|
});
|
||||||
|
|
||||||
|
map.on('mouseenter', 'clusters', () => {
|
||||||
|
map.getCanvas().style.cursor = 'pointer';
|
||||||
|
});
|
||||||
|
map.on('mouseleave', 'clusters', () => {
|
||||||
|
map.getCanvas().style.cursor = '';
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_rescue_orgs %}
|
||||||
// Load rescue_orgs as geojson
|
// Load rescue_orgs as geojson
|
||||||
map.addSource('rescue-orgs', {
|
map.addSource('rescue-orgs', {
|
||||||
type: 'geojson',
|
type: 'geojson',
|
||||||
@@ -171,20 +244,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// inspect an AN cluster on click
|
|
||||||
map.on('click', 'clusters', async (e) => {
|
|
||||||
const features = map.queryRenderedFeatures(e.point, {
|
|
||||||
layers: ['clusters']
|
|
||||||
});
|
|
||||||
const clusterId = features[0].properties.cluster_id;
|
|
||||||
const zoom = await map.getSource('adoption-notices').getClusterExpansionZoom(clusterId);
|
|
||||||
map.easeTo({
|
|
||||||
center: features[0].geometry.coordinates,
|
|
||||||
zoom
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// inspect an org cluster on click
|
// inspect an org cluster on click
|
||||||
map.on('click', 'org-clusters', async (e) => {
|
map.on('click', 'org-clusters', async (e) => {
|
||||||
const features = map.queryRenderedFeatures(e.point, {
|
const features = map.queryRenderedFeatures(e.point, {
|
||||||
@@ -198,56 +257,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// When a click event occurs on a feature in
|
|
||||||
// the unclustered-point layer, open a popup at
|
|
||||||
// the location of the feature, with
|
|
||||||
// description HTML from its properties.
|
|
||||||
map.on('click', 'unclustered-point', (e) => {
|
|
||||||
const coordinates = e.features[0].geometry.coordinates.slice();
|
|
||||||
const title = e.features[0].properties.title;
|
|
||||||
const url = e.features[0].properties.url;
|
|
||||||
const description = e.features[0].properties.description;
|
|
||||||
const location_hr = e.features[0].properties.location_hr;
|
|
||||||
const image_url = e.features[0].properties.image_url;
|
|
||||||
const image_alt = e.features[0].properties.image_alt;
|
|
||||||
|
|
||||||
// Ensure that if the map is zoomed out such that
|
|
||||||
// multiple copies of the feature are visible, the
|
|
||||||
// popup appears over the copy being pointed to.
|
|
||||||
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
|
|
||||||
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
|
|
||||||
}
|
|
||||||
|
|
||||||
const description_column = `
|
|
||||||
<div class="column">
|
|
||||||
<strong><a class="is-size-7" href="${url}">${title}</a></strong> <i class="fa-solid fa-arrow-up-right-from-square"></i><br>
|
|
||||||
<span><strong>{% translate 'Ort' %}</strong>: ${location_hr}</span><br>
|
|
||||||
<p class="is-size-7">${truncate(description, 80, url)}</p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
let picture_column = '';
|
|
||||||
if (image_url) {
|
|
||||||
picture_column = `
|
|
||||||
<div class="column">
|
|
||||||
<figure class="image is-128x128">
|
|
||||||
<img src="${image_url}" alt="${image_alt}"/>
|
|
||||||
</figure>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
new maplibregl.Popup()
|
|
||||||
.setLngLat(coordinates)
|
|
||||||
.setHTML(`
|
|
||||||
<div class="popup-content is-size-7">
|
|
||||||
<div class="columns">
|
|
||||||
${description_column}
|
|
||||||
${picture_column}
|
|
||||||
</div>
|
|
||||||
</div>`
|
|
||||||
)
|
|
||||||
.addTo(map);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Same for orgs
|
// Same for orgs
|
||||||
map.on('click', 'org-unclustered-point', (e) => {
|
map.on('click', 'org-unclustered-point', (e) => {
|
||||||
const coordinates = e.features[0].geometry.coordinates.slice();
|
const coordinates = e.features[0].geometry.coordinates.slice();
|
||||||
@@ -273,12 +282,6 @@
|
|||||||
.addTo(map);
|
.addTo(map);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('mouseenter', 'clusters', () => {
|
|
||||||
map.getCanvas().style.cursor = 'pointer';
|
|
||||||
});
|
|
||||||
map.on('mouseleave', 'clusters', () => {
|
|
||||||
map.getCanvas().style.cursor = '';
|
|
||||||
});
|
|
||||||
|
|
||||||
map.on('mouseenter', 'org-clusters', () => {
|
map.on('mouseenter', 'org-clusters', () => {
|
||||||
map.getCanvas().style.cursor = 'pointer';
|
map.getCanvas().style.cursor = 'pointer';
|
||||||
@@ -286,6 +289,7 @@
|
|||||||
map.on('mouseleave', 'org-clusters', () => {
|
map.on('mouseleave', 'org-clusters', () => {
|
||||||
map.getCanvas().style.cursor = '';
|
map.getCanvas().style.cursor = '';
|
||||||
});
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
image = await map.loadImage('{% static "fellchensammlung/img/pin.png" %}');
|
image = await map.loadImage('{% static "fellchensammlung/img/pin.png" %}');
|
||||||
map.addImage('pin', image.data);
|
map.addImage('pin', image.data);
|
||||||
|
@@ -142,7 +142,6 @@ def adoption_notice_detail(request, adoption_notice_id):
|
|||||||
return render(request, 'fellchensammlung/details/bulma-detail-adoption-notice.html', context=context)
|
return render(request, 'fellchensammlung/details/bulma-detail-adoption-notice.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def adoption_notice_edit(request, adoption_notice_id):
|
def adoption_notice_edit(request, adoption_notice_id):
|
||||||
"""
|
"""
|
||||||
@@ -178,14 +177,14 @@ def search_important_locations(request, important_location_slug):
|
|||||||
"place_not_found": search.place_not_found,
|
"place_not_found": search.place_not_found,
|
||||||
"subscribed_search": None,
|
"subscribed_search": None,
|
||||||
"searched": False,
|
"searched": False,
|
||||||
"adoption_notices_map": AdoptionNotice.get_active_ANs(),
|
|
||||||
"map_center": search.position,
|
"map_center": search.position,
|
||||||
"search_center": search.position,
|
"search_center": search.position,
|
||||||
"map_pins": [search],
|
"map_pins": [search],
|
||||||
"location": search.location,
|
"location": search.location,
|
||||||
"search_radius": search.max_distance,
|
"search_radius": search.max_distance,
|
||||||
"zoom_level": zoom_level_for_radius(search.max_distance),
|
"zoom_level": zoom_level_for_radius(search.max_distance),
|
||||||
"geocoding_api_url": settings.GEOCODING_API_URL, }
|
"geocoding_api_url": settings.GEOCODING_API_URL,
|
||||||
|
"show_ANs": True}
|
||||||
return render(request, 'fellchensammlung/bulma-search.html', context=context)
|
return render(request, 'fellchensammlung/bulma-search.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
@@ -220,14 +219,14 @@ def search(request, templatename="fellchensammlung/bulma-search.html"):
|
|||||||
"place_not_found": search.place_not_found,
|
"place_not_found": search.place_not_found,
|
||||||
"subscribed_search": subscribed_search,
|
"subscribed_search": subscribed_search,
|
||||||
"searched": searched,
|
"searched": searched,
|
||||||
"adoption_notices_map": AdoptionNotice.get_active_ANs(),
|
|
||||||
"map_center": search.position,
|
"map_center": search.position,
|
||||||
"search_center": search.position,
|
"search_center": search.position,
|
||||||
"map_pins": [search],
|
"map_pins": [search],
|
||||||
"location": search.location,
|
"location": search.location,
|
||||||
"search_radius": search.max_distance,
|
"search_radius": search.max_distance,
|
||||||
"zoom_level": zoom_level_for_radius(search.max_distance),
|
"zoom_level": zoom_level_for_radius(search.max_distance),
|
||||||
"geocoding_api_url": settings.GEOCODING_API_URL, }
|
"geocoding_api_url": settings.GEOCODING_API_URL,
|
||||||
|
"show_ANs": True}
|
||||||
return render(request, templatename, context=context)
|
return render(request, templatename, context=context)
|
||||||
|
|
||||||
|
|
||||||
@@ -298,7 +297,6 @@ def adoption_notice_add_animal(request, adoption_notice_id):
|
|||||||
return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form})
|
return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def add_photo_to_animal_bulma(request, animal_id):
|
def add_photo_to_animal_bulma(request, animal_id):
|
||||||
animal = Animal.objects.get(id=animal_id)
|
animal = Animal.objects.get(id=animal_id)
|
||||||
@@ -597,8 +595,12 @@ def updatequeue(request):
|
|||||||
"adoption_notices_active": adoption_notices_active}
|
"adoption_notices_active": adoption_notices_active}
|
||||||
return render(request, 'fellchensammlung/updatequeue.html', context=context)
|
return render(request, 'fellchensammlung/updatequeue.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
def map_bulma(request):
|
def map_bulma(request):
|
||||||
return map(request, templatename='fellchensammlung/bulma-map.html')
|
context = {"show_ANs": True,
|
||||||
|
"show_rescue_orgs": True}
|
||||||
|
|
||||||
|
return render(request, 'fellchensammlung/bulma-map.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
def metrics(request):
|
def metrics(request):
|
||||||
@@ -675,7 +677,8 @@ def external_site_warning(request, template_name='fellchensammlung/bulma-externa
|
|||||||
|
|
||||||
def list_rescue_organizations(request, template='fellchensammlung/bulma-animal-shelters.html'):
|
def list_rescue_organizations(request, template='fellchensammlung/bulma-animal-shelters.html'):
|
||||||
rescue_organizations = RescueOrganization.objects.all()
|
rescue_organizations = RescueOrganization.objects.all()
|
||||||
context = {"rescue_organizations": rescue_organizations}
|
context = {"rescue_organizations": rescue_organizations,
|
||||||
|
"show_rescue_orgs": True}
|
||||||
return render(request, template, context=context)
|
return render(request, template, context=context)
|
||||||
|
|
||||||
|
|
||||||
@@ -683,8 +686,7 @@ def detail_view_rescue_organization(request, rescue_organization_id,
|
|||||||
template='fellchensammlung/details/bulma-detail-rescue-organization.html'):
|
template='fellchensammlung/details/bulma-detail-rescue-organization.html'):
|
||||||
org = RescueOrganization.objects.get(pk=rescue_organization_id)
|
org = RescueOrganization.objects.get(pk=rescue_organization_id)
|
||||||
return render(request, template,
|
return render(request, template,
|
||||||
context={"org": org, "map_center": org.position, "zoom_level": 6, "rescue_organizations": [org]})
|
context={"org": org, "map_center": org.position, "zoom_level": 6, "map_pins": [org]})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def export_own_profile(request):
|
def export_own_profile(request):
|
||||||
@@ -699,7 +701,6 @@ def export_own_profile(request):
|
|||||||
return HttpResponse(full_json, content_type="application/json")
|
return HttpResponse(full_json, content_type="application/json")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def rescue_organization_check(request):
|
def rescue_organization_check(request):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
Reference in New Issue
Block a user