mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Review roster API
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
{{ site_conf.footer_extended | markdown | safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% if site_conf.show_version %}
|
||||
|
||||
<div class="container">
|
||||
<p class="small text-muted">Made with ❤️ and <a href="https://github.com/daniviga/django-ram">django-ram</a> version {{ site_conf.version }}</p>
|
||||
<p class="small text-muted">Made with ❤️ for 🚂 and <a href="https://github.com/daniviga/django-ram">django-ram</a>
|
||||
{% if site_conf.show_version %}<br/>Version {{ site_conf.version }}{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</footer>
|
||||
|
@@ -29,18 +29,18 @@ urlpatterns = [
|
||||
path("api/v1/dcc/", include("driver.urls")),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# if settings.DEBUG:
|
||||
# from django.views.generic import TemplateView
|
||||
# from rest_framework.schemas import get_schema_view
|
||||
#
|
||||
# urlpatterns += [
|
||||
# path('swagger/', TemplateView.as_view(
|
||||
# template_name='swagger.html',
|
||||
# extra_context={'schema_url': 'openapi-schema'}
|
||||
# ), name='swagger'),
|
||||
# path('openapi', get_schema_view(
|
||||
# title="BITE - A Basic/IoT/Example",
|
||||
# description="BITE API for IoT",
|
||||
# version="1.0.0"
|
||||
# ), name='openapi-schema'),
|
||||
# ]
|
||||
if settings.DEBUG:
|
||||
from django.views.generic import TemplateView
|
||||
from rest_framework.schemas import get_schema_view
|
||||
|
||||
urlpatterns += [
|
||||
path('swagger/', TemplateView.as_view(
|
||||
template_name='swagger.html',
|
||||
extra_context={'schema_url': 'openapi-schema'}
|
||||
), name='swagger'),
|
||||
path('openapi', get_schema_view(
|
||||
title="RAM - Railroad Assets Manager",
|
||||
description="RAM API",
|
||||
version="1.0.0"
|
||||
), name='openapi-schema'),
|
||||
]
|
||||
|
@@ -1,9 +1,9 @@
|
||||
from django.urls import path
|
||||
from roster.views import RosterList, RosterGet, RosterAddress, RosterIdentifier
|
||||
from roster.views import RosterList, RosterGet, RosterAddress, RosterClass
|
||||
|
||||
urlpatterns = [
|
||||
path("list", RosterList.as_view()),
|
||||
path("get/<str:uuid>", RosterGet.as_view()),
|
||||
path("address/<int:address>", RosterAddress.as_view()),
|
||||
path("identifier/<str:identifier>", RosterIdentifier.as_view()),
|
||||
path("class/<str:class>", RosterClass.as_view()),
|
||||
]
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from rest_framework.generics import ListAPIView, RetrieveAPIView
|
||||
from rest_framework.schemas.openapi import AutoSchema
|
||||
|
||||
from roster.models import RollingStock
|
||||
from roster.serializers import RollingStockSerializer
|
||||
@@ -14,14 +15,30 @@ class RosterGet(RetrieveAPIView):
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "uuid"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByUUID"
|
||||
)
|
||||
|
||||
|
||||
class RosterAddress(ListAPIView):
|
||||
queryset = RollingStock.objects.all()
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "address"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByAddress"
|
||||
)
|
||||
|
||||
def get_queryset(self):
|
||||
address = self.kwargs["address"]
|
||||
return RollingStock.objects.filter(address=address)
|
||||
|
||||
|
||||
class RosterIdentifier(RetrieveAPIView):
|
||||
queryset = RollingStock.objects.all()
|
||||
class RosterClass(ListAPIView):
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "identifier"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByClass"
|
||||
)
|
||||
|
||||
def get_queryset(self):
|
||||
_class = self.kwargs["class"]
|
||||
return RollingStock.objects.filter(rolling_class__identifier=_class)
|
||||
|
Reference in New Issue
Block a user