Skip to content

Commit

Permalink
Pridaný endpoint pre typy publikacii
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe committed Dec 8, 2023
1 parent 01fc3f5 commit 4742c87
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions competition/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions competition/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
13 changes: 9 additions & 4 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
EventSerializer, GradeSerializer,
LateTagSerializer, ProblemSerializer,
ProblemWithSolutionsSerializer,
PublicationSerializer, SemesterSerializer,
PublicationSerializer,
PublicationTypeSerializer,
SemesterSerializer,
SemesterWithProblemsSerializer,
SeriesWithProblemsSerializer,
SolutionSerializer)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4742c87

Please sign in to comment.