Commit ec40675e authored by Einar Uvsløkk's avatar Einar Uvsløkk
Browse files

Move api_root to secfit module

parent a4998508
Pipeline #127927 passed with stage
in 49 seconds
......@@ -19,8 +19,11 @@ from django.contrib import admin
from django.urls import include
from django.urls import path
from secfit import views
urlpatterns = [
path("admin/", admin.site.urls),
path("", views.api_root),
path("", include("comments.urls")),
path("", include("users.urls")),
path("", include("workouts.urls")),
......
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.reverse import reverse
@api_view(["GET"])
def api_root(request, format=None):
return Response(
{
"users": reverse("user-list", request=request, format=format),
"workouts": reverse("workout-list", request=request, format=format),
"exercises": reverse("exercise-list", request=request, format=format),
"exercise-instances": reverse(
"exercise-instance-list", request=request, format=format
),
"workout-files": reverse(
"workout-file-list", request=request, format=format
),
"comments": reverse("comment-list", request=request, format=format),
"likes": reverse("like-list", request=request, format=format),
}
)
......@@ -5,7 +5,6 @@ from workouts import views
urlpatterns = format_suffix_patterns(
[
path("", views.api_root),
path("api/workouts/", views.WorkoutList.as_view(), name="workout-list"),
path(
"api/workouts/<int:pk>/",
......
......@@ -9,10 +9,7 @@ from rest_framework import filters
from rest_framework import generics
from rest_framework import mixins
from rest_framework import permissions
from rest_framework.decorators import api_view
from rest_framework.parsers import JSONParser
from rest_framework.response import Response
from rest_framework.reverse import reverse
from workouts.mixins import CreateListModelMixin
from workouts.models import Exercise
......@@ -35,25 +32,6 @@ from workouts.serializers import WorkoutFileSerializer
from workouts.serializers import WorkoutSerializer
@api_view(["GET"])
def api_root(request, format=None):
return Response(
{
"users": reverse("user-list", request=request, format=format),
"workouts": reverse("workout-list", request=request, format=format),
"exercises": reverse("exercise-list", request=request, format=format),
"exercise-instances": reverse(
"exercise-instance-list", request=request, format=format
),
"workout-files": reverse(
"workout-file-list", request=request, format=format
),
"comments": reverse("comment-list", request=request, format=format),
"likes": reverse("like-list", request=request, format=format),
}
)
class WorkoutList(
mixins.ListModelMixin, mixins.CreateModelMixin, generics.GenericAPIView
):
......
Supports Markdown
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