added prediction viewset to views.py

This commit is contained in:
afanasyev.aa 2025-07-02 04:32:44 +09:00
parent 7ee58ce501
commit 57fdcaa0e9
3 changed files with 88 additions and 81 deletions

View file

@ -1,28 +1,35 @@
from django.urls import path
from .views import (PredictionCreateView, PredictionListView,
PredictionHistoryListView,
PredictionHistoryDetailView,
PredictionHistoryDeleteView,
SessionView,
WhoAmIView,
from rest_framework.routers import DefaultRouter
from rest_framework.authtoken.views import obtain_auth_token
from .views import (
PredictionViewSet,
SavedPointViewset,
TelemetryListCreateView,
get_csrf,
login_view,
logout_view)
from rest_framework.authtoken.views import obtain_auth_token
from .views import TelemetryListCreateView
logout_view,
SessionView,
WhoAmIView
)
router = DefaultRouter()
router.register(r'predictions', PredictionViewSet, basename='predictions')
router.register(r'saved-points', SavedPointViewset, basename='saved-points')
urlpatterns = [
path('predictions', PredictionCreateView.as_view(), name='create_prediction'),
path('predictions/list/', PredictionListView.as_view(), name='get_predictions'),
path("csrf/", get_csrf, name='api-csrf'),
path('token', obtain_auth_token, name = 'get_token'),
path("history", PredictionHistoryListView.as_view(), name='view_history_list'),
path("history/<uuid:pk>/", PredictionHistoryDetailView.as_view(), name='view_history_detail'),
path("history/<uuid:pk>/delete/", PredictionHistoryDeleteView.as_view(), name='delete_history'),
path("login/", login_view, name='api-login'),
path("logout/", logout_view, name='api-logout'),
path("session/", SessionView.as_view(), name='api-session'),
path("whoami/", WhoAmIView.as_view(), name='api-whoami'),
path("<uuid:pk>/telemetry/", TelemetryListCreateView.as_view(), name="create_telemetry"),
path('saved-points/', SavedPointViewset.as_view({'get': 'list', 'post': 'create', 'put': 'update', 'delete': 'destroy'}), name='saved_points'),
path('csrf/', get_csrf, name='api-csrf'),
path('login/', login_view, name='api-login'),
path('logout/', logout_view, name='api-logout'),
path('session/', SessionView.as_view(), name='api-session'), # new
path('whoami/', WhoAmIView.as_view(), name='api-whoami'), # new
]
urlpatterns += router.urls