Добавил геофильтры. Теперь нужен рефакторинг.
This commit is contained in:
@@ -126,6 +126,7 @@ class ShowSourcesMapView(LoginRequiredMixin, View):
|
||||
"""View for displaying selected sources on map."""
|
||||
|
||||
def get(self, request):
|
||||
import json
|
||||
from ..models import Source
|
||||
|
||||
ids = request.GET.get("ids", "")
|
||||
@@ -168,8 +169,18 @@ class ShowSourcesMapView(LoginRequiredMixin, View):
|
||||
else:
|
||||
return redirect("mainapp:home")
|
||||
|
||||
# Get polygon filter from URL if present
|
||||
polygon_coords_str = request.GET.get("polygon", "").strip()
|
||||
polygon_coords = None
|
||||
if polygon_coords_str:
|
||||
try:
|
||||
polygon_coords = json.loads(polygon_coords_str)
|
||||
except (json.JSONDecodeError, ValueError, TypeError):
|
||||
polygon_coords = None
|
||||
|
||||
context = {
|
||||
"groups": groups,
|
||||
"polygon_coords": json.dumps(polygon_coords) if polygon_coords else None,
|
||||
}
|
||||
return render(request, "mainapp/source_map.html", context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user