Refactoring of cart services (#414)

This commit is contained in:
Raphael Michel
2017-02-21 17:15:43 +01:00
committed by GitHub
parent 33e7a10bea
commit 09020143e7
5 changed files with 297 additions and 177 deletions

View File

@@ -282,11 +282,12 @@ class Order(LoggedModel):
if self.event.settings.get('payment_term_last'):
if now() > self.event.payment_term_last:
return error_messages['late_lastdate']
if not self.event.settings.get('payment_term_accept_late'):
return error_messages['late']
if self.status == self.STATUS_PENDING:
return True
if not self.event.settings.get('payment_term_accept_late'):
return error_messages['late']
return self._is_still_available()
def _is_still_available(self, now_dt: datetime=None) -> Union[bool, str]:

View File

@@ -210,11 +210,11 @@ class Voucher(LoggedModel):
Returns whether this voucher applies to a given item (and optionally
a variation).
"""
if self.quota:
return item.quotas.filter(pk=self.quota.pk).exists()
if self.item and not self.variation:
return self.item == item
return (self.item == item) and (self.variation == variation)
if self.quota_id:
return item.quotas.filter(pk=self.quota_id).exists()
if self.item_id and not self.variation_id:
return self.item_id == item.pk
return (self.item_id == item.pk) and (variation and self.variation_id == variation.pk)
def is_active(self):
"""