From 53e54e5dfdb6c530f8238e7be671afb2dbcc13d0 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Mon, 29 Jul 2024 19:05:33 +0000 Subject: [PATCH] feat: Add rest viewsets for file item and network models --- uvdat/core/rest/__init__.py | 6 ++++++ uvdat/core/rest/file_item.py | 9 +++++++++ uvdat/core/rest/network.py | 23 +++++++++++++++++++++++ uvdat/urls.py | 8 ++++++++ 4 files changed, 46 insertions(+) create mode 100644 uvdat/core/rest/file_item.py create mode 100644 uvdat/core/rest/network.py diff --git a/uvdat/core/rest/__init__.py b/uvdat/core/rest/__init__.py index 88706ca7..6bc2c50e 100644 --- a/uvdat/core/rest/__init__.py +++ b/uvdat/core/rest/__init__.py @@ -1,15 +1,21 @@ from .chart import ChartViewSet from .context import ContextViewSet from .dataset import DatasetViewSet +from .file_item import FileItemViewSet from .map_layers import RasterMapLayerViewSet, VectorMapLayerViewSet +from .network import NetworkEdgeViewSet, NetworkNodeViewSet, NetworkViewSet from .regions import DerivedRegionViewSet, SourceRegionViewSet from .simulations import SimulationViewSet __all__ = [ ContextViewSet, ChartViewSet, + FileItemViewSet, RasterMapLayerViewSet, VectorMapLayerViewSet, + NetworkViewSet, + NetworkNodeViewSet, + NetworkEdgeViewSet, DatasetViewSet, SourceRegionViewSet, DerivedRegionViewSet, diff --git a/uvdat/core/rest/file_item.py b/uvdat/core/rest/file_item.py new file mode 100644 index 00000000..1e8e8154 --- /dev/null +++ b/uvdat/core/rest/file_item.py @@ -0,0 +1,9 @@ +from rest_framework.viewsets import ModelViewSet + +from uvdat.core.models import FileItem +from uvdat.core.rest.serializers import FileItemSerializer + + +class FileItemViewSet(ModelViewSet): + queryset = FileItem.objects.all() + serializer_class = FileItemSerializer diff --git a/uvdat/core/rest/network.py b/uvdat/core/rest/network.py new file mode 100644 index 00000000..3e42cbae --- /dev/null +++ b/uvdat/core/rest/network.py @@ -0,0 +1,23 @@ +from rest_framework.viewsets import ModelViewSet + +from uvdat.core.models import Network, NetworkEdge, NetworkNode +from uvdat.core.rest.serializers import ( + NetworkEdgeSerializer, + NetworkNodeSerializer, + NetworkSerializer, +) + + +class NetworkViewSet(ModelViewSet): + queryset = Network.objects.all() + serializer_class = NetworkSerializer + + +class NetworkNodeViewSet(ModelViewSet): + queryset = NetworkNode.objects.all() + serializer_class = NetworkNodeSerializer + + +class NetworkEdgeViewSet(ModelViewSet): + queryset = NetworkEdge.objects.all() + serializer_class = NetworkEdgeSerializer diff --git a/uvdat/urls.py b/uvdat/urls.py index 5be1d17c..06f204ea 100644 --- a/uvdat/urls.py +++ b/uvdat/urls.py @@ -10,6 +10,10 @@ ContextViewSet, DatasetViewSet, DerivedRegionViewSet, + FileItemViewSet, + NetworkEdgeViewSet, + NetworkNodeViewSet, + NetworkViewSet, RasterMapLayerViewSet, SimulationViewSet, SourceRegionViewSet, @@ -26,9 +30,13 @@ router.register(r'contexts', ContextViewSet, basename='contexts') router.register(r'datasets', DatasetViewSet, basename='datasets') +router.register(r'files', FileItemViewSet, basename='files') router.register(r'charts', ChartViewSet, basename='charts') router.register(r'rasters', RasterMapLayerViewSet, basename='rasters') router.register(r'vectors', VectorMapLayerViewSet, basename='vectors') +router.register(r'networks', NetworkViewSet, basename='networks') +router.register(r'nodes', NetworkNodeViewSet, basename='nodes') +router.register(r'edges', NetworkEdgeViewSet, basename='edges') router.register(r'source-regions', SourceRegionViewSet, basename='source-regions') router.register(r'derived-regions', DerivedRegionViewSet, basename='derived-regions') router.register(r'simulations', SimulationViewSet, basename='simulations')