diff --git a/competition/serializers.py b/competition/serializers.py index dbcfa665..5f7622ee 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 6e316606..6e5a8c02 100644 --- a/competition/urls.py +++ b/competition/urls.py @@ -18,6 +18,8 @@ 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) +router.register(r'publication-type', views.PublicationTypeViewSet) urlpatterns = [] diff --git a/competition/views.py b/competition/views.py index fd88360f..548b6a3c 100644 --- a/competition/views.py +++ b/competition/views.py @@ -17,19 +17,22 @@ 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, ProblemWithSolutionsSerializer, - PublicationSerializer, SemesterSerializer, + PublicationSerializer, + PublicationTypeSerializer, + SemesterSerializer, SemesterWithProblemsSerializer, SeriesWithProblemsSerializer, SolutionSerializer) @@ -118,6 +121,11 @@ def slug(self, request: Request, slug: str = None) -> Response: ) +class CompetitionTypeViewSet(viewsets.ReadOnlyModelViewSet): + queryset = CompetitionType.objects.all() + serializer_class = CompetitionTypeSerializer + + class CommentViewSet( mixins.RetrieveModelMixin, mixins.DestroyModelMixin, @@ -809,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()