Verified Commit 00d915fb authored by David Haynes's avatar David Haynes 🙆
Browse files

Add /alerts endpoint to API

- get the list of alerts
	- todo: remove alerts that have expired or
		are no longer in effect
parent 1b6fb77d
Pipeline #1384 passed with stage
in 1 minute and 8 seconds
......@@ -329,4 +329,4 @@ class Alert(TimeStampedModel):
"""
String representation of an Alert object.
"""
return "%s | %s" % (self.message, self.urgency_tag)
return "%s" % (self.message)
......@@ -15,7 +15,7 @@ from django.views.generic.base import RedirectView
# App Imports
from .views import (CategoryViewSet, FacilityViewSet, ScheduleViewSet,
LocationViewSet)
LocationViewSet, AlertViewSet)
# Other Imports
from rest_framework.routers import DefaultRouter
......@@ -28,6 +28,7 @@ ROUTER.register(r'categories', CategoryViewSet)
ROUTER.register(r'facilities', FacilityViewSet)
ROUTER.register(r'schedules', ScheduleViewSet)
ROUTER.register(r'locations', LocationViewSet)
ROUTER.register(r'alerts', AlertViewSet)
urlpatterns = [
# / - Default route
......
......@@ -8,14 +8,20 @@ from __future__ import (absolute_import, division, print_function,
unicode_literals)
# App Imports
from .models import Facility, OpenTime, Category, Schedule, Location
from .models import Facility, OpenTime, Category, Schedule, Location, Alert
from .serializers import (CategorySerializer, FacilitySerializer,
ScheduleSerializer, OpenTimeSerializer,
LocationSerializer)
LocationSerializer, AlertSerializer)
# Other Imports
from rest_framework import viewsets
class AlertViewSet(viewsets.ReadOnlyModelViewSet):
"""
"""
queryset = Alert.objects.all()
serializer_class = AlertSerializer
class CategoryViewSet(viewsets.ReadOnlyModelViewSet):
"""
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment