def validate(self, data): data = super().validate(data) Item.clean_per_order(data.get('min_per_order'), data.get('max_per_order')) Item.clean_available(data.get('available_from'), data.get('available_until')) return data
def validate(self, data): data = super().validate(data) if self.instance and ('addons' in data or 'variations' in data): raise ValidationError(_('Updating add-ons or variations via PATCH/PUT is not supported. Please use the ' 'dedicated nested endpoint.')) Item.clean_per_order(data.get('min_per_order'), data.get('max_per_order')) Item.clean_available(data.get('available_from'), data.get('available_until')) return data
def validate(self, data): data = super().validate(data) if self.instance and ('addons' in data or 'variations' in data or 'bundles' in data): raise ValidationError(_('Updating add-ons, bundles, or variations via PATCH/PUT is not supported. Please use the ' 'dedicated nested endpoint.')) Item.clean_per_order(data.get('min_per_order'), data.get('max_per_order')) Item.clean_available(data.get('available_from'), data.get('available_until')) if data.get('issue_giftcard'): if data.get('tax_rule') and data.get('tax_rule').rate > 0: raise ValidationError( _("Gift card products should not be associated with non-zero tax rates since sales tax will be " "applied when the gift card is redeemed.") ) if data.get('admission'): raise ValidationError(_( "Gift card products should not be admission products at the same time." )) return data