From 01fc3f50124b6b55de24484c5de778e5684ecd08 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 8 Dec 2023 22:44:44 +0100 Subject: [PATCH 1/2] Pridan7 endpoint pre competition-type --- competition/urls.py | 1 + competition/views.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/competition/urls.py b/competition/urls.py index 6e316606..79032a54 100644 --- a/competition/urls.py +++ b/competition/urls.py @@ -18,6 +18,7 @@ router.register(r'grade', views.GradeViewSet) router.register(r'problem-administration', views.ProblemAdministrationViewSet) router.register(r'event-registration', views.EventRegistrationViewSet) +router.register(r'competition-type', views.CompetitionTypeViewSet) urlpatterns = [] diff --git a/competition/views.py b/competition/views.py index fd88360f..fa8324ea 100644 --- a/competition/views.py +++ b/competition/views.py @@ -17,14 +17,15 @@ from base.utils import mime_type from competition import utils -from competition.models import (Comment, Competition, Event, EventRegistration, - Grade, LateTag, Problem, Publication, - PublicationType, Semester, Series, Solution, - Vote) +from competition.models import (Comment, Competition, CompetitionType, Event, + EventRegistration, Grade, LateTag, Problem, + Publication, PublicationType, Semester, Series, + Solution, Vote) from competition.permissions import (CommentPermission, CompetitionRestrictedPermission, ProblemPermission) from competition.serializers import (CommentSerializer, CompetitionSerializer, + CompetitionTypeSerializer, EventRegistrationSerializer, EventSerializer, GradeSerializer, LateTagSerializer, ProblemSerializer, @@ -118,6 +119,13 @@ def slug(self, request: Request, slug: str = None) -> Response: ) +class CompetitionTypeViewSet(mixins.RetrieveModelMixin, + mixins.ListModelMixin, + viewsets.GenericViewSet): + queryset = CompetitionType.objects.all() + serializer_class = CompetitionTypeSerializer + + class CommentViewSet( mixins.RetrieveModelMixin, mixins.DestroyModelMixin, From 4742c87db67050da942b40d28e679ea99b2e6f8f Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 8 Dec 2023 22:51:48 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Pridan=C3=BD=20endpoint=20pre=20typy=20publ?= =?UTF-8?q?ikacii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- competition/serializers.py | 7 +++++++ competition/urls.py | 1 + competition/views.py | 13 +++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/competition/serializers.py b/competition/serializers.py index 9f37b0bc..66da30ee 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -27,6 +27,13 @@ def get_is_registered(self, obj): return None +@ts_interface(context='competition') +class PublicationTypeSerializer(serializers.ModelSerializer): + class Meta: + model = models.PublicationType + fields = '__all__' + + @ts_interface(context='competition') class PublicationSerializer(serializers.ModelSerializer): class Meta: diff --git a/competition/urls.py b/competition/urls.py index 79032a54..6e5a8c02 100644 --- a/competition/urls.py +++ b/competition/urls.py @@ -19,6 +19,7 @@ router.register(r'problem-administration', views.ProblemAdministrationViewSet) router.register(r'event-registration', views.EventRegistrationViewSet) router.register(r'competition-type', views.CompetitionTypeViewSet) +router.register(r'publication-type', views.PublicationTypeViewSet) urlpatterns = [] diff --git a/competition/views.py b/competition/views.py index fa8324ea..548b6a3c 100644 --- a/competition/views.py +++ b/competition/views.py @@ -30,7 +30,9 @@ EventSerializer, GradeSerializer, LateTagSerializer, ProblemSerializer, ProblemWithSolutionsSerializer, - PublicationSerializer, SemesterSerializer, + PublicationSerializer, + PublicationTypeSerializer, + SemesterSerializer, SemesterWithProblemsSerializer, SeriesWithProblemsSerializer, SolutionSerializer) @@ -119,9 +121,7 @@ def slug(self, request: Request, slug: str = None) -> Response: ) -class CompetitionTypeViewSet(mixins.RetrieveModelMixin, - mixins.ListModelMixin, - viewsets.GenericViewSet): +class CompetitionTypeViewSet(viewsets.ReadOnlyModelViewSet): queryset = CompetitionType.objects.all() serializer_class = CompetitionTypeSerializer @@ -817,6 +817,11 @@ class EventRegistrationViewSet(viewsets.ModelViewSet): permission_classes = (CompetitionRestrictedPermission,) +class PublicationTypeViewSet(viewsets.ReadOnlyModelViewSet): + queryset = PublicationType.objects.all() + serializer_class = PublicationTypeSerializer + + class PublicationViewSet(viewsets.ModelViewSet): """Publikácie(výsledky, brožúrky, časopisy, ...)""" queryset = Publication.objects.all()