From 4c97c791d8d76c274c60f542d94f0c8c17692ba4 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 15 Aug 2018 13:32:40 +0500 Subject: [PATCH] LIL-582, contest works autoload on scroll, check that user uploaded work and etc --- api/v1/serializers/contest.py | 2 -- api/v1/views.py | 5 ++++ apps/content/templates/content/contest.html | 5 +--- web/src/components/ContestWorks.vue | 33 +++++++++++++++++++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/api/v1/serializers/contest.py b/api/v1/serializers/contest.py index 930f60f3..dc5b88fd 100644 --- a/api/v1/serializers/contest.py +++ b/api/v1/serializers/contest.py @@ -64,7 +64,5 @@ class ContestWorkCreateSerializer(serializers.ModelSerializer): model = ContestWork fields = '__all__' - # TODO check ContestWork.objects.filter(user=self.request.user).exists() - def to_representation(self, instance): return ContestWorkSerializer(instance=instance, context=self.context).to_representation(instance) diff --git a/api/v1/views.py b/api/v1/views.py index 4fc23d73..a3be3d39 100644 --- a/api/v1/views.py +++ b/api/v1/views.py @@ -469,3 +469,8 @@ class ContestWorkViewSet(ExtendedModelViewSet): 'retrieve': ContestWorkSerializer, } filter_fields = ('contest',) + + def create(self, request, *args, **kwargs): + if ContestWork.objects.filter(user=request.user).exists(): + return Response(status=status.HTTP_400_BAD_REQUEST) + return super().create(request, *args, **kwargs) diff --git a/apps/content/templates/content/contest.html b/apps/content/templates/content/contest.html index 4c8a9f2f..f0ed5d37 100644 --- a/apps/content/templates/content/contest.html +++ b/apps/content/templates/content/contest.html @@ -33,11 +33,8 @@
- + {% endblock content %} - -{% block foot %} -{% endblock foot %} diff --git a/web/src/components/ContestWorks.vue b/web/src/components/ContestWorks.vue index af193876..9e8a5c92 100644 --- a/web/src/components/ContestWorks.vue +++ b/web/src/components/ContestWorks.vue @@ -6,24 +6,51 @@