Add settings page and configurable network map types.

Let users define sector/circle labels and geometry per map type, choose a type when creating maps, and sync types through local backup and API migrations.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-25 10:45:34 +03:00
co-authored by Cursor
parent cafc7335ad
commit e80d0d0e88
29 changed files with 1370 additions and 117 deletions
+16 -2
View File
@@ -1,11 +1,13 @@
from rest_framework import viewsets
from rest_framework.exceptions import ValidationError
from .models import Contact, Relation, NetworkMap, NetworkMapMembership
from .models import Contact, Relation, NetworkMap, NetworkMapMembership, NetworkMapType
from .serializers import (
ContactSerializer,
RelationSerializer,
NetworkMapSerializer,
NetworkMapMembershipSerializer,
NetworkMapTypeSerializer,
)
@@ -27,10 +29,22 @@ class RelationViewSet(viewsets.ModelViewSet):
class NetworkMapViewSet(viewsets.ModelViewSet):
queryset = NetworkMap.objects.all()
queryset = NetworkMap.objects.select_related('map_type').all()
serializer_class = NetworkMapSerializer
class NetworkMapTypeViewSet(viewsets.ModelViewSet):
queryset = NetworkMapType.objects.all()
serializer_class = NetworkMapTypeSerializer
def perform_destroy(self, instance):
if instance.is_default:
raise ValidationError({'detail': 'Нельзя удалить тип карты по умолчанию.'})
if instance.maps.exists():
raise ValidationError({'detail': 'Тип используется картами сети. Сначала смените тип у карт.'})
instance.delete()
class NetworkMapMembershipViewSet(viewsets.ModelViewSet):
serializer_class = NetworkMapMembershipSerializer