add: add new domain for cors
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
CORS_ALLOWED_ORIGINS = [
|
CORS_ALLOWED_ORIGINS = [
|
||||||
"http://localhost:5173",
|
"http://localhost:5173",
|
||||||
|
"http://localhost:3000",
|
||||||
"http://127.0.0.1:5173",
|
"http://127.0.0.1:5173",
|
||||||
'https://agro360.vercel.app',
|
'https://agro360.vercel.app',
|
||||||
|
'https://agro360-admin.vercel.app',
|
||||||
]
|
]
|
||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = [
|
CSRF_TRUSTED_ORIGINS = [
|
||||||
|
|||||||
@@ -3,16 +3,23 @@ from rest_framework import serializers
|
|||||||
from core.apps.products.models import Product
|
from core.apps.products.models import Product
|
||||||
|
|
||||||
|
|
||||||
# class ProductListSerializer(serializers.ModelSerializer):
|
class ProductListSerializer(serializers.ModelSerializer):
|
||||||
# class Meta:
|
class Meta:
|
||||||
# model = Product
|
model = Product
|
||||||
# fields = [
|
fields = [
|
||||||
# 'id', 'name', 'image', 'category', 'price', 'description', 'unity'
|
'id', 'name', 'image', 'category', 'price', 'description', 'unity'
|
||||||
# ]
|
]
|
||||||
|
|
||||||
# def get_category(self, obj):
|
def get_category(self, obj):
|
||||||
# return {
|
return {
|
||||||
# ''
|
'id': obj.category.id,
|
||||||
# }
|
'name': obj.category.name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ProductCreateSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Product
|
||||||
|
fields = [
|
||||||
|
'name', 'image', 'category', 'price', 'description', 'unity'
|
||||||
|
]
|
||||||
23
core/apps/admin_panel/views/product.py
Normal file
23
core/apps/admin_panel/views/product.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from rest_framework import generics, views
|
||||||
|
from rest_framework.permissions import IsAdminUser
|
||||||
|
|
||||||
|
from core.apps.admin_panel.serializers import product as serializers
|
||||||
|
from core.apps.shared.mixins.response import ResponseMixin
|
||||||
|
from core.apps.products.models import Product
|
||||||
|
|
||||||
|
|
||||||
|
class ProductListApiView(generics.GenericAPIView):
|
||||||
|
serializer_class = serializers.ProductListSerializer
|
||||||
|
queryset = Product.objects.select_related('category', 'unity')
|
||||||
|
permission_classes = [IsAdminUser]
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
page = self.paginate_queryset(self.queryset)
|
||||||
|
if page is not None:
|
||||||
|
serializer = self.serializer_class(page, many=True)
|
||||||
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
|
# class ProductCreateApiView(generics.GenericAPIView, ResponseMixin):
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user