Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

283 vytvoriť readonly endpoint pre competitiontype a publicationtype #296

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading