API: Add write operations to taxrules resource

This commit is contained in:
Raphael Michel
2017-10-11 00:09:53 +02:00
parent e06be9ee25
commit a0e7bd3996
7 changed files with 239 additions and 18 deletions

View File

@@ -81,6 +81,16 @@ class TaxRule(LoggedModel):
'if configured above.'),
)
def allow_delete(self):
from pretix.base.models.orders import OrderFee, OrderPosition
return (
not OrderFee.objects.filter(tax_rule=self, order__event=self.event).exists()
and not OrderPosition.objects.filter(tax_rule=self, order__event=self.event).exists()
and not self.event.items.filter(tax_rule=self).exists()
and self.event.settings.tax_rate_default != self
)
@classmethod
def zero(cls):
return cls(