2023-01-19 19:35:25 +00:00
|
|
|
"""timetracker URL Configuration
|
2022-12-31 13:18:27 +00:00
|
|
|
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
|
|
https://docs.djangoproject.com/en/4.1/topics/http/urls/
|
|
|
|
Examples:
|
|
|
|
Function views
|
|
|
|
1. Add an import: from my_app import views
|
|
|
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
|
|
Class-based views
|
|
|
|
1. Add an import: from other_app.views import Home
|
|
|
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
|
|
Including another URLconf
|
|
|
|
1. Import the include() function: from django.urls import include, path
|
|
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
|
|
"""
|
2023-01-15 22:39:52 +00:00
|
|
|
from django.conf import settings
|
2022-12-31 13:18:27 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.urls import include, path
|
|
|
|
from django.views.generic import RedirectView
|
2023-01-25 11:05:37 +00:00
|
|
|
from rest_framework import routers, serializers, viewsets
|
|
|
|
from games.models import Game, Purchase, Platform, Session
|
|
|
|
|
|
|
|
|
|
|
|
class GameSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Game
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class PlatformSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Platform
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class PurchaseSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Purchase
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class SessionSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Session
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class GameViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Game.objects.all()
|
|
|
|
serializer_class = GameSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class PlatformViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Platform.objects.all()
|
|
|
|
serializer_class = PlatformSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class PurchaseViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Purchase.objects.all()
|
|
|
|
serializer_class = PurchaseSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class SessionViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Session.objects.all()
|
|
|
|
serializer_class = SessionSerializer
|
|
|
|
|
|
|
|
|
|
|
|
router = routers.DefaultRouter()
|
|
|
|
router.register(r"games", GameViewSet)
|
|
|
|
router.register(r"platforms", PlatformViewSet)
|
|
|
|
router.register(r"purchases", PurchaseViewSet)
|
|
|
|
router.register(r"sessions", SessionViewSet)
|
|
|
|
|
2022-12-31 13:18:27 +00:00
|
|
|
|
|
|
|
urlpatterns = [
|
2023-01-30 21:16:28 +00:00
|
|
|
path("", RedirectView.as_view(url="/tracker")),
|
|
|
|
path("tracker/", include("games.urls")),
|
2022-12-31 13:18:27 +00:00
|
|
|
]
|
2023-01-07 20:59:54 +00:00
|
|
|
|
2023-11-16 15:25:34 +00:00
|
|
|
if settings.DEBUG:
|
|
|
|
urlpatterns.append(path("admin/", admin.site.urls))
|