Skip to content

Commit

Permalink
Fixed get_queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruzal committed Nov 13, 2023
1 parent 1da435d commit 96798cb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from drf_yasg.utils import swagger_auto_schema
from rest_framework import filters, generics, mixins, status, viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied
from rest_framework.permissions import SAFE_METHODS, AllowAny
from rest_framework.response import Response
from taggit.models import Tag
Expand Down Expand Up @@ -167,11 +166,13 @@ def update(self, request, *args, **kwargs):
return Response(
{"detail": message}, status=status.HTTP_403_FORBIDDEN
)
if instance.status_approve == Project.APPROVED and \
instance.end_datetime < timezone.now():
if (
instance.status_approve == Project.APPROVED
and instance.end_datetime < timezone.now()
):
return Response(
{"detail": "Вы не можете редактировать завершенные проекты"},
status=status.HTTP_400_BAD_REQUEST
status=status.HTTP_400_BAD_REQUEST,
)
partial = kwargs.pop('partial', False)
serializer = self.get_serializer(
Expand All @@ -198,10 +199,13 @@ def destroy(self, request, *args, **kwargs):
)
# Проверяем статус проекта возможно нужно еще добавить какие то статусы
if instance.status_approve not in [
Project.EDITING, Project.CANCELED_BY_ORGANIZER
Project.EDITING,
Project.CANCELED_BY_ORGANIZER,
]:
message = ('Вы не можете удалить проекты, '
'не находящиеся в архиве или в черновике.')
message = (
'Вы не можете удалить проекты, '
'не находящиеся в архиве или в черновике.'
)
return Response(
{"detail": message}, status=status.HTTP_400_BAD_REQUEST
)
Expand Down

0 comments on commit 96798cb

Please sign in to comment.