feat: show radius and center map

This commit is contained in:
2025-01-01 20:14:07 +01:00
parent 3881a4f3b4
commit 8b4488484d
4 changed files with 75 additions and 15 deletions

View File

@@ -1,4 +1,6 @@
import logging
from collections import namedtuple
import requests
import json
from math import radians, sqrt, sin, cos, atan2
@@ -6,6 +8,8 @@ from math import radians, sqrt, sin, cos, atan2
from notfellchen import __version__ as nf_version
from notfellchen import settings
Position = namedtuple('Position', ['latitude', 'longitude'])
def calculate_distance_between_coordinates(position1, position2):
"""

View File

@@ -1,7 +1,7 @@
import logging
from django.utils.translation import gettext_lazy as _
from .geo import GeoAPI, LocationProxy
from .geo import LocationProxy, Position
from ..forms import AdoptionNoticeSearchForm
from ..models import SearchSubscription, AdoptionNotice, AdoptionNoticeNotification, SexChoicesWithAll, Location
@@ -69,6 +69,13 @@ class Search:
except ValueError:
self.place_not_found = True
@property
def position(self):
if self.area_search and not self.place_not_found:
return Position(latitude=self.location.latitude, longitude=self.location.longitude)
else:
return None
def adoption_notice_fits_search(self, adoption_notice: AdoptionNotice):
# Make sure sex is set and sex is not set to all (then it can be disregarded)
if self.sex is not None and self.sex != SexChoicesWithAll.ALL: