diff --git a/DjangoFiles/ApiBillet/serializers.py b/DjangoFiles/ApiBillet/serializers.py new file mode 100644 index 0000000..a87b99b --- /dev/null +++ b/DjangoFiles/ApiBillet/serializers.py @@ -0,0 +1,17 @@ +from rest_framework import serializers +from BaseBillet.models import Event + +class EventSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Event + fields = [ + 'name', + 'short_description', + 'long_description', + 'datetime', + # 'billets', + # 'articles', + 'img', + # 'reservations', + # 'complet', + ] diff --git a/DjangoFiles/ApiBillet/urls.py b/DjangoFiles/ApiBillet/urls.py new file mode 100644 index 0000000..76a63dc --- /dev/null +++ b/DjangoFiles/ApiBillet/urls.py @@ -0,0 +1,13 @@ +from django.urls import include, path, re_path + +# from BaseBillet import views as base_view +from ApiBillet import views as api_view +from rest_framework import routers + +router = routers.DefaultRouter() +router.register(r'events', api_view.EventViewSet) + + +urlpatterns = [ + path('', include(router.urls)), +] \ No newline at end of file diff --git a/DjangoFiles/ApiBillet/views.py b/DjangoFiles/ApiBillet/views.py index f55c3fc..221dba1 100644 --- a/DjangoFiles/ApiBillet/views.py +++ b/DjangoFiles/ApiBillet/views.py @@ -1,7 +1,11 @@ from django.shortcuts import render # Create your views here. +from ApiBillet.serializers import EventSerializer from Customers.models import Client, Domain +from BaseBillet.models import Event +from rest_framework import viewsets, permissions + import os def new_tenants(schema_name): @@ -18,3 +22,14 @@ def new_tenants(schema_name): ) return tenant, tenant_domain + + + + +class EventViewSet(viewsets.ModelViewSet): + """ + API endpoint that allows users to be viewed or edited. + """ + queryset = Event.objects.all().order_by('-datetime') + serializer_class = EventSerializer + permission_classes = [permissions.AllowAny] diff --git a/DjangoFiles/TiBillet/settings.py b/DjangoFiles/TiBillet/settings.py index 4238f51..5d6f317 100644 --- a/DjangoFiles/TiBillet/settings.py +++ b/DjangoFiles/TiBillet/settings.py @@ -153,6 +153,8 @@ REST_FRAMEWORK = { "rest_framework_simplejwt.authentication.JWTAuthentication", "rest_framework.authentication.TokenAuthentication", ), + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', + 'PAGE_SIZE': 10 } SIMPLE_JWT = { diff --git a/DjangoFiles/TiBillet/urls_tenants.py b/DjangoFiles/TiBillet/urls_tenants.py index e052c60..4da9246 100644 --- a/DjangoFiles/TiBillet/urls_tenants.py +++ b/DjangoFiles/TiBillet/urls_tenants.py @@ -31,6 +31,9 @@ urlpatterns = [ re_path(r'^user/', include('AuthBillet.urls')), + re_path(r'api/', include('ApiBillet.urls')), + + path('', include('BaseBillet.urls')), # path('admin/', admin.site.urls, name="public_admin_url"), diff --git a/README.md b/README.md index a810595..04d1863 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Enjoy ! Jonas TURBEAUX & Nicolas DIJOUX pour Peaks2Prod & 3Peaks Production. -Free for personal and commercial use under the MIT 3.0 license +Free for personal and commercial use under the AGPL-3.0 licence. ## Graphisme :