Skip to content

Commit

Permalink
sources apis
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed May 15, 2024
1 parent 9b8eba8 commit de6ef15
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

router = routers.DefaultRouter()
router.register(r"maps", views.MapViewSet, basename="maps")
router.register(r"sources", views.SourceViewSet, basename="sources")
router.register(r"raster-sources", views.RasterSourceViewSet, basename="raster-sources")
router.register(r"vector-sources", views.VectorSourceViewSet, basename="vector-sources")
router.register(r"layer-groups", views.LayerGroupViewSet, basename="layer-groups")
Expand Down
13 changes: 13 additions & 0 deletions metadata_catalogue/maps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ class Meta:
]


class SourceSerializer(serializers.ModelSerializer):
class Meta:
model = Source
fields = [
"name",
"slug",
"extra",
"style",
"attribution",
"metadata",
]


class RasterSourceBaseSerializer(serializers.ModelSerializer):
class Meta:
model = RasterSource
Expand Down
9 changes: 8 additions & 1 deletion metadata_catalogue/maps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from rest_framework.parsers import MultiPartParser
from rest_framework.response import Response

from ..models import Layer, LayerGroup, Map, RasterSource, VectorSource
from ..models import Layer, LayerGroup, Map, RasterSource, Source, VectorSource
from .serializers import (
FileUploadSerializer,
LayerGroupSerializer,
LayerSerializer,
MapSerializer,
RasterSourceSerializer,
SourceSerializer,
VectorSourceSerializer,
)

Expand All @@ -29,6 +30,12 @@ class MapViewSet(viewsets.ModelViewSet):
}


class SourceViewSet(viewsets.ModelViewSet):
queryset = Source.objects.all()
lookup_field = "slug"
serializer_class = SourceSerializer


class UploadableMixin:
@action(detail=True, methods=["post"], parser_classes=(MultiPartParser,))
def upload(self, request, *args, **kwargs):
Expand Down

0 comments on commit de6ef15

Please sign in to comment.