Skip to content

Commit

Permalink
Merge pull request #296 from ZdruzenieSTROM/283-vytvoriť-readonly-end…
Browse files Browse the repository at this point in the history
…point-pre-competitiontype-a-publicationtype

283 vytvoriť readonly endpoint pre competitiontype a publicationtype
  • Loading branch information
mmihalik authored Dec 8, 2023
2 parents aa6e62a + 4742c87 commit 2906174
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 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
2 changes: 2 additions & 0 deletions competition/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
23 changes: 18 additions & 5 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2906174

Please sign in to comment.