Добавлены посещённые организации

main
through-your-tears 9 months ago
parent 76f0ac2962
commit 23656b1a88

@ -47,3 +47,7 @@ class QRCodeUsingRepository(BaseRepository):
start_date, end_date = cls.__get_dates_from_timestamp(timestamp) start_date, end_date = cls.__get_dates_from_timestamp(timestamp)
return cls.model.objects.filter(organization__pk=organization_id, used_dt__gte=start_date, return cls.model.objects.filter(organization__pk=organization_id, used_dt__gte=start_date,
used_dt__lt=end_date).count() used_dt__lt=end_date).count()
@classmethod
def get_organizations(cls, user):
return cls.model.objects.filter(client=user)

@ -13,5 +13,6 @@ urlpatterns = [
path('categories/', CategoryListAPIView.as_view()), path('categories/', CategoryListAPIView.as_view()),
path('map/', OrganizationMapFilterAPIView.as_view()), path('map/', OrganizationMapFilterAPIView.as_view()),
path('owner/', OwnerOrganizationListAPIView.as_view()), path('owner/', OwnerOrganizationListAPIView.as_view()),
path('visited/', VisitedOrganizationsListAPIView.as_view())
# path('upload/', UploadAPIView.as_view()) # path('upload/', UploadAPIView.as_view())
] + router.urls ] + router.urls

@ -11,6 +11,7 @@ from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from core.permissions import IsAuthorOrReadOnly from core.permissions import IsAuthorOrReadOnly
from business.repositories import QRCodeUsingRepository
from .repositories import CategoryRepository, OrganizationRepository from .repositories import CategoryRepository, OrganizationRepository
from .serializers import CategorySerializer, OrganizationListSerializer, OrganizationCreateSerializer from .serializers import CategorySerializer, OrganizationListSerializer, OrganizationCreateSerializer
from .services import parse_organizations_to_db from .services import parse_organizations_to_db
@ -113,6 +114,15 @@ class OwnerOrganizationListAPIView(ListAPIView):
return OrganizationRepository.get_by_owner(self.request.user) return OrganizationRepository.get_by_owner(self.request.user)
class VisitedOrganizationsListAPIView(ListAPIView):
serializer_class = OrganizationListSerializer
pagination_class = PageNumberPagination
permission_classes = [IsAuthenticated]
def get_queryset(self):
return QRCodeUsingRepository.get_organizations(self.request.user)
class UploadAPIView(APIView): class UploadAPIView(APIView):
def post(self, request): def post(self, request):

Loading…
Cancel
Save