Добавлены QR коды и управление работниками

main
through-your-tears 9 months ago
parent 38b7a1864e
commit 76f0ac2962

@ -49,6 +49,10 @@ class OrganizationRepository(BaseRepository):
rectangle = Polygon.from_bbox((*coords1, *coords2))
return cls.get_by_categories(categories).filter(location__coords__within=rectangle)
@classmethod
def get_by_owner(cls, owner):
return cls.model.objects.filter(owner=owner)
class OrganizationImagesRepository(BaseRepository):
model = OrganizationImage

@ -1,7 +1,7 @@
from django.urls import path
from rest_framework.routers import DefaultRouter
from .views import OrganizationViewSet, OrganizationSearchListAPIView, OrganizationByCategoryListAPIView, CategoryListAPIView, OrganizationMapFilterAPIView, UploadAPIView
from .views import *
app_name = "organizations"
@ -11,6 +11,7 @@ urlpatterns = [
path('category/<int:id>/organizations/', OrganizationByCategoryListAPIView.as_view()),
path('search/<str:name>/', OrganizationSearchListAPIView.as_view()),
path('categories/', CategoryListAPIView.as_view()),
path('map/', OrganizationMapFilterAPIView.as_view())
path('map/', OrganizationMapFilterAPIView.as_view()),
path('owner/', OwnerOrganizationListAPIView.as_view()),
# path('upload/', UploadAPIView.as_view())
] + router.urls

@ -5,6 +5,7 @@ from django.views.decorators.vary import vary_on_cookie
from rest_framework import status
from rest_framework.generics import ListAPIView
from rest_framework.pagination import PageNumberPagination
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
@ -103,6 +104,15 @@ class OrganizationByCategoryListAPIView(ListAPIView):
return OrganizationRepository.all()
class OwnerOrganizationListAPIView(ListAPIView):
permission_classes = [IsAuthenticated]
pagination_class = PageNumberPagination
serializer_class = OrganizationListSerializer
def get_queryset(self):
return OrganizationRepository.get_by_owner(self.request.user)
class UploadAPIView(APIView):
def post(self, request):

Loading…
Cancel
Save