Skip to content

Commit

Permalink
Add endpoint for reading enviromental_justice data
Browse files Browse the repository at this point in the history
  • Loading branch information
code-geek committed Feb 2, 2024
1 parent 059f3c2 commit 9742eb8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
26 changes: 26 additions & 0 deletions environmental_justice/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from rest_framework import serializers

from .models import EnvironmentalJusticeRow


class EnvironmentalJusticeRowSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = EnvironmentalJusticeRow
fields = [
"dataset",
"description",
"description_simplified",
"indicators",
"intended_use",
"latency",
"limitations",
"project",
"source_link",
"strengths",
"format",
"geographic_coverage",
"data_visualization",
"spatial_resolution",
"temporal_extent",
"temporal_resolution",
]
18 changes: 16 additions & 2 deletions environmental_justice/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
from django.shortcuts import render # noqa
from rest_framework import permissions, viewsets

# Create your views here.
from .models import EnvironmentalJusticeRow
from .serializers import EnvironmentalJusticeRowSerializer


class EnvironmentalJusticeRowViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows environmental justice rows to be read.
"""

queryset = EnvironmentalJusticeRow.objects.all()
serializer_class = EnvironmentalJusticeRowSerializer
permission_classes = [permissions.IsAuthenticated]
http_method_names = [
"get",
]
3 changes: 3 additions & 0 deletions sde_collections/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.urls import include, path
from rest_framework import routers

from environmental_justice.views import EnvironmentalJusticeRowViewSet

from . import views

router = routers.DefaultRouter()
Expand All @@ -11,6 +13,7 @@
router.register(r"include-patterns", views.IncludePatternViewSet)
router.register(r"title-patterns", views.TitlePatternViewSet)
router.register(r"document-type-patterns", views.DocumentTypePatternViewSet)
router.register(r"environmental-justice", EnvironmentalJusticeRowViewSet)

app_name = "sde_collections"

Expand Down

0 comments on commit 9742eb8

Please sign in to comment.