Skip to content

Commit

Permalink
feat: Add rest viewsets for file item and network models
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Aug 2, 2024
1 parent 95c8c8a commit 53e54e5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions uvdat/core/rest/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
9 changes: 9 additions & 0 deletions uvdat/core/rest/file_item.py
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions uvdat/core/rest/network.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions uvdat/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
ContextViewSet,
DatasetViewSet,
DerivedRegionViewSet,
FileItemViewSet,
NetworkEdgeViewSet,
NetworkNodeViewSet,
NetworkViewSet,
RasterMapLayerViewSet,
SimulationViewSet,
SourceRegionViewSet,
Expand All @@ -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')
Expand Down

0 comments on commit 53e54e5

Please sign in to comment.