Skip to content

Commit

Permalink
fix filter, delete comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Shtanskiy committed Apr 13, 2024
1 parent 1492875 commit 9377ebc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/backend/api/v1/profile/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from apps.profile.models import Profile


class SpecialistsFilter(FilterSet):
class ProfileFilter(FilterSet):
"""Класс фильтрации специалистов, по запросу на главной странице."""

ready_to_participate = filters.BooleanFilter()
Expand Down
8 changes: 4 additions & 4 deletions src/backend/api/v1/projects/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ProjectFilter(FilterSet):
ended = filters.DateFromToRangeFilter()
recruitment_status = filters.MultipleChoiceFilter(
choices=(
("open", "Набор открыт"),
("closed", "Набор закрыт"),
("1", "Набор открыт"),
("2", "Набор закрыт"),
),
method="filter_recruitment_status",
)
Expand All @@ -42,12 +42,12 @@ class Meta:
)

def filter_recruitment_status(self, queryset, name, value):
if value == "open":
if value == "1":
queryset = queryset.filter(
Q(project_specialists__is_requred=True)
| ~Q(project_specialists__is_required=False)
)
elif value == "closed":
elif value == "2":
queryset = queryset.filter(
~Q(project_specialists__is_reqiered=True),
Q(project_specialists__is_required=False),
Expand Down
33 changes: 1 addition & 32 deletions src/backend/api/v1/projects/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.contrib.auth.models import AnonymousUser
from django.db.models import Prefetch, Q
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import mixins # decorators, mixins, status
from rest_framework import mixins
from rest_framework.permissions import SAFE_METHODS, AllowAny, IsAuthenticated

# from rest_framework.response import Response
from rest_framework.viewsets import (
GenericViewSet,
ModelViewSet,
Expand Down Expand Up @@ -138,35 +136,6 @@ class ProjectPreviewMainViewSet(mixins.ListModelMixin, GenericViewSet):
serializer_class = ProjectPreviewMainSerializer
pagination_class = ProjectPreviewMainPagination

# @decorators.action(
# detail=False,
# methods=[
# "GET",
# "UPDATE",
# "DELETE",
# ],
# url_path=r"my_projects",
# permission_classes=[
# IsCreatorOrOwnerOrReadOnly,
# ],
# )
# def my_projects(self, request, **kwargs):
# """Превью поектов в личном кабинете для участника или владельцы."""
# projects = self.get_object()
# if self.action == "GET":
# return projects
# elif self.action == "UPDATE":
# instance = self.get_object()
# serializer = self.get_serializer(
# instance, data=request.data, partial=True
# )
# serializer.is_valid(raise_exception=True)
# serializer.save()
# return Response(serializer.data, status=status.HTTP_200_OK)
# else:
# projects.filter(id=self.kwargs.get("pk")).delete()
# return Response(status=status.HTTP_204_NO_CONTENT)


class DraftViewSet(BaseProjectViewSet, ModelViewSet):
"""Представление для черновиков проекта."""
Expand Down

0 comments on commit 9377ebc

Please sign in to comment.