mirror of
https://github.com/pretix/pretix.git
synced 2026-08-25 13:12:00 +00:00
API: fix tax rules create default handling (#6490)
* API: fix tax rules create default handling * fix flake8
This commit is contained in:
@@ -702,8 +702,12 @@ class TaxRuleSerializer(CountryFieldMixin, I18nAwareModelSerializer):
|
||||
return super().save(**kwargs)
|
||||
|
||||
def validate_default(self, value):
|
||||
if not value and self.instance.default:
|
||||
raise ValidationError("You can't remove the default property, instead set it on another tax rule.")
|
||||
if not value:
|
||||
if self.instance:
|
||||
if self.instance.default:
|
||||
raise ValidationError("You can't remove the default property, instead set it on another tax rule.")
|
||||
elif not self.context["event"].tax_rules.exists():
|
||||
raise ValidationError("You can't remove the default property as there is only one tax rule.")
|
||||
return value
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user