categorylanri import qilish qoshildi
This commit is contained in:
21
core/apps/vendors/views/vendor.py
vendored
21
core/apps/vendors/views/vendor.py
vendored
@@ -11,6 +11,9 @@ from core.apps.vendors.serializers.vendor import CreateVendorSerializer, ListVen
|
|||||||
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
@extend_schema(tags=["vendor"])
|
@extend_schema(tags=["vendor"])
|
||||||
class VendorView(BaseViewSetMixin, ModelViewSet):
|
class VendorView(BaseViewSetMixin, ModelViewSet):
|
||||||
queryset = VendorModel.objects.all()
|
queryset = VendorModel.objects.all()
|
||||||
@@ -27,4 +30,22 @@ class VendorView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"create": CreateVendorSerializer,
|
"create": CreateVendorSerializer,
|
||||||
"update": CreateVendorSerializer,
|
"update": CreateVendorSerializer,
|
||||||
"partial_update": CreateVendorSerializer,
|
"partial_update": CreateVendorSerializer,
|
||||||
|
"destroy": ListVendorSerializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
|
||||||
|
lookup_value = self.kwargs[lookup_url_kwarg]
|
||||||
|
|
||||||
|
# Qidirish: firestore_id yoki id bo'yicha
|
||||||
|
if lookup_value.isdigit():
|
||||||
|
obj = queryset.filter(Q(id=lookup_value) | Q(firestore_id=lookup_value)).first()
|
||||||
|
else:
|
||||||
|
obj = queryset.filter(firestore_id=lookup_value).first()
|
||||||
|
|
||||||
|
if obj is None:
|
||||||
|
return get_object_or_404(queryset, **{self.lookup_field: lookup_value})
|
||||||
|
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|||||||
21
core/apps/vendors/views/vendor_product.py
vendored
21
core/apps/vendors/views/vendor_product.py
vendored
@@ -19,6 +19,9 @@ from django_filters.rest_framework import DjangoFilterBackend
|
|||||||
from core.apps.vendors.filters.vendor_product import ProductimageFilter, VendorproductFilter
|
from core.apps.vendors.filters.vendor_product import ProductimageFilter, VendorproductFilter
|
||||||
from core.apps.vendors.pagination import VendorProductCursorPagination
|
from core.apps.vendors.pagination import VendorProductCursorPagination
|
||||||
|
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
@extend_schema(tags=["VendorProduct"])
|
@extend_schema(tags=["VendorProduct"])
|
||||||
class VendorproductView(BaseViewSetMixin, ModelViewSet):
|
class VendorproductView(BaseViewSetMixin, ModelViewSet):
|
||||||
queryset = VendorproductModel.objects.all().order_by("-created_at")
|
queryset = VendorproductModel.objects.all().order_by("-created_at")
|
||||||
@@ -36,8 +39,26 @@ class VendorproductView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"create": CreateVendorproductSerializer,
|
"create": CreateVendorproductSerializer,
|
||||||
"update": CreateVendorproductSerializer,
|
"update": CreateVendorproductSerializer,
|
||||||
"partial_update": CreateVendorproductSerializer,
|
"partial_update": CreateVendorproductSerializer,
|
||||||
|
"destroy": ListVendorproductSerializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
|
||||||
|
lookup_value = self.kwargs[lookup_url_kwarg]
|
||||||
|
|
||||||
|
# Qidirish: firestore_id yoki id bo'yicha
|
||||||
|
if lookup_value.isdigit():
|
||||||
|
obj = queryset.filter(Q(id=lookup_value) | Q(firestore_id=lookup_value)).first()
|
||||||
|
else:
|
||||||
|
obj = queryset.filter(firestore_id=lookup_value).first()
|
||||||
|
|
||||||
|
if obj is None:
|
||||||
|
return get_object_or_404(queryset, **{self.lookup_field: lookup_value})
|
||||||
|
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@extend_schema(tags=["ProductImage"])
|
@extend_schema(tags=["ProductImage"])
|
||||||
class ProductimageView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
class ProductimageView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
|||||||
26
fondex_backup.sql
Normal file
26
fondex_backup.sql
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
--
|
||||||
|
-- PostgreSQL database dump
|
||||||
|
--
|
||||||
|
|
||||||
|
\restrict godIWJQQxgiDG9fLAin0wtdYBSNVXeB9yLZgnWTYkgJMVB0J3uxpFg9ZPE6G5tf
|
||||||
|
|
||||||
|
-- Dumped from database version 16.11 (Debian 16.11-1.pgdg13+1)
|
||||||
|
-- Dumped by pg_dump version 16.11 (Debian 16.11-1.pgdg13+1)
|
||||||
|
|
||||||
|
SET statement_timeout = 0;
|
||||||
|
SET lock_timeout = 0;
|
||||||
|
SET idle_in_transaction_session_timeout = 0;
|
||||||
|
SET client_encoding = 'UTF8';
|
||||||
|
SET standard_conforming_strings = on;
|
||||||
|
SELECT pg_catalog.set_config('search_path', '', false);
|
||||||
|
SET check_function_bodies = false;
|
||||||
|
SET xmloption = content;
|
||||||
|
SET client_min_messages = warning;
|
||||||
|
SET row_security = off;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- PostgreSQL database dump complete
|
||||||
|
--
|
||||||
|
|
||||||
|
\unrestrict godIWJQQxgiDG9fLAin0wtdYBSNVXeB9yLZgnWTYkgJMVB0J3uxpFg9ZPE6G5tf
|
||||||
|
|
||||||
Reference in New Issue
Block a user