Добавил геофильтры. Теперь нужен рефакторинг.

This commit is contained in:
2025-11-17 17:44:24 +03:00
parent b889fb29a3
commit c0f2f16303
7 changed files with 385 additions and 2 deletions

View File

@@ -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)