mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Refs #105 -- Variation support for vouchers
This commit is contained in:
@@ -493,17 +493,18 @@ class Quota(LoggedModel):
|
||||
def count_blocking_vouchers(self) -> int:
|
||||
from pretix.base.models import Voucher
|
||||
return Voucher.objects.filter(
|
||||
item__quotas__in=[self],
|
||||
block_quota=True,
|
||||
redeemed=False
|
||||
Q(item__quotas__in=[self]) &
|
||||
Q(block_quota=True) &
|
||||
Q(redeemed=False) &
|
||||
self._position_lookup
|
||||
).count()
|
||||
|
||||
def count_in_cart(self) -> int:
|
||||
from pretix.base.models import CartPosition
|
||||
|
||||
return CartPosition.objects.filter(
|
||||
Q(expires__gte=now())
|
||||
& self._position_lookup
|
||||
Q(expires__gte=now()) &
|
||||
self._position_lookup
|
||||
).count()
|
||||
|
||||
def count_orders(self) -> dict:
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .base import LoggedModel
|
||||
from .event import Event
|
||||
from .items import Item
|
||||
from .items import Item, ItemVariation
|
||||
from .orders import CartPosition, OrderPosition
|
||||
|
||||
|
||||
@@ -63,6 +63,14 @@ class Voucher(LoggedModel):
|
||||
"This product is added to the user's cart if the voucher is redeemed."
|
||||
)
|
||||
)
|
||||
variation = models.ForeignKey(
|
||||
ItemVariation, related_name='vouchers',
|
||||
null=True, blank=True,
|
||||
verbose_name=_("Product variation"),
|
||||
help_text=_(
|
||||
"This variation of the product select above is being used."
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Voucher")
|
||||
|
||||
Reference in New Issue
Block a user