update special_discount_link method to return a URL based on user authentication
This commit is contained in:
@@ -88,7 +88,11 @@ class ProductVariantSerialzier(serializers.ModelSerializer):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_special_discount_link(self, obj):
|
def get_special_discount_link(self, obj):
|
||||||
return 'https://'
|
request = self.context.get('request')
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
return 'https://google.com'
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_price_after_discount(self, obj):
|
def get_price_after_discount(self, obj):
|
||||||
return f'{obj.price_after_discount:,.0f} تومانءءء'
|
return f'{obj.price_after_discount:,.0f} تومانءءء'
|
||||||
|
|||||||
Reference in New Issue
Block a user