add bot categories
This commit is contained in:
@@ -471,4 +471,29 @@ class BotProductDetailView(APIView):
|
||||
'name': product.name,
|
||||
'banner' : product.bot_banner,
|
||||
'link': f'https://heymlz.com/product/{product.slug}'
|
||||
})
|
||||
})
|
||||
|
||||
class BotCategorySerializer(serializers.ModelSerializer):
|
||||
link = serializers.SerializerMethodField()
|
||||
class Meta:
|
||||
model = MainCategoryModel
|
||||
fields = ['pk', 'name', 'link']
|
||||
def get_link(self, obj):
|
||||
return f'https://heymlz.com/products/category/{obj.slug}'
|
||||
|
||||
class BotCategoryView(APIView):
|
||||
serializer_class = BotCategorySerializer
|
||||
def get(self, request):
|
||||
categories = MainCategoryModel.objects.all()
|
||||
categories_ser = self.serializer_class(categories, many=True)
|
||||
|
||||
if categories.exists():
|
||||
return Response({
|
||||
"success": True,
|
||||
"categories": categories_ser.data
|
||||
})
|
||||
else:
|
||||
return Response({
|
||||
"success": False,
|
||||
"categories": []
|
||||
})
|
||||
Reference in New Issue
Block a user