* Check the Gifts that are being added to Checklist from unauthorized users
This commit is contained in:
parent
ca478a7e15
commit
6f96eaaac7
|
|
@ -1,6 +1,7 @@
|
|||
from drf_extra_fields.fields import Base64ImageField
|
||||
from rest_framework import serializers
|
||||
|
||||
from store.exceptions import CRMException
|
||||
from store.models import User, Checklist, GlobalSettings, Category, PaymentMethod, Promocode, Image, Gift
|
||||
from store.utils import get_primary_key_related_model
|
||||
|
||||
|
|
@ -195,7 +196,13 @@ class AnonymousUserChecklistSerializer(ChecklistSerializer):
|
|||
'buyername', 'buyerphone',
|
||||
'delivery',
|
||||
'recievername', 'recieverphone', 'tg',
|
||||
'cdek_barcode_pdf'})
|
||||
'gift', 'cdek_barcode_pdf'})
|
||||
|
||||
def validate(self, attrs):
|
||||
gift = attrs.get('gift')
|
||||
if gift is not None and self.instance.price_yuan < gift.min_price:
|
||||
raise CRMException("Can't add gift: price of order < min_price of gift")
|
||||
return attrs
|
||||
|
||||
|
||||
class GlobalSettingsSerializer(serializers.ModelSerializer):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user