def validate(self, data): data = super().validate(data) ItemAddOn.clean_max_min_count(data.get('max_count'), data.get('min_count')) return data
def validate_addons(self, value): if not self.instance: for addon_data in value: ItemAddOn.clean_categories(self.context['event'], None, self.instance, addon_data['addon_category']) ItemAddOn.clean_min_count(addon_data['min_count']) ItemAddOn.clean_max_count(addon_data['max_count']) ItemAddOn.clean_max_min_count(addon_data['max_count'], addon_data['min_count']) return value
def validate_addons(self, value): if self.instance is not None: raise ValidationError( _('Updating add-ons via PATCH/PUT is not supported. Please use the dedicated' ' nested endpoint.')) else: for addon_data in value: ItemAddOn.clean_categories(self.context['event'], None, self.instance, addon_data['addon_category']) ItemAddOn.clean_min_count(addon_data['min_count']) ItemAddOn.clean_max_count(addon_data['max_count']) ItemAddOn.clean_max_min_count(addon_data['max_count'], addon_data['min_count']) return value