示例#1
0
    def validate(self, data):
        data = super().validate(data)

        ItemAddOn.clean_max_min_count(data.get('max_count'),
                                      data.get('min_count'))

        return data
示例#2
0
文件: item.py 项目: regnat/pretix
 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
示例#3
0
 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
示例#4
0
 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
示例#5
0
    def validate(self, data):
        data = super().validate(data)

        ItemAddOn.clean_max_min_count(data.get('max_count'), data.get('min_count'))

        return data