feat: add DRF serializers for CRM admin, suppliers, products, wallets, and orders
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 34s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 34s
This commit is contained in:
parent
ce1871a727
commit
8eb5b39a99
1 changed files with 16 additions and 0 deletions
|
|
@ -50,8 +50,24 @@ class SupplierProfileSerializer(serializers.ModelSerializer):
|
|||
model = SupplierProfile
|
||||
fields = ['id', 'name', 'email', 'phone', 'gstin', 'status', 'joined_at']
|
||||
|
||||
import re
|
||||
|
||||
CDN_DOMAIN = "https://d1zlxfmkt834bg.cloudfront.net"
|
||||
|
||||
def get_cdn_url(image_url):
|
||||
if not image_url:
|
||||
return image_url
|
||||
if 'betasupplierdocumentstorage' in image_url or 's3.ap-south-2.amazonaws.com' in image_url or '.s3.amazonaws.com' in image_url:
|
||||
path = re.sub(r'^https?://[^/]+/', '', image_url)
|
||||
return f"{CDN_DOMAIN}/{path}"
|
||||
return image_url
|
||||
|
||||
class ProductSerializer(serializers.ModelSerializer):
|
||||
name = serializers.CharField(read_only=True)
|
||||
image = serializers.SerializerMethodField()
|
||||
|
||||
def get_image(self, obj):
|
||||
return get_cdn_url(obj.image)
|
||||
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
|
||||
supplier_status = serializers.CharField(source='supplier.status', read_only=True)
|
||||
supplier_phone = serializers.CharField(source='supplier.phone', read_only=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue