mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Fix missing Discount.is_available_by_time method
This commit is contained in:
@@ -28,6 +28,7 @@ from typing import Dict, Optional, Tuple
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||||
from django_scopes import ScopedManager
|
from django_scopes import ScopedManager
|
||||||
|
|
||||||
@@ -198,6 +199,14 @@ class Discount(LoggedModel):
|
|||||||
'subevent_mode': self.subevent_mode,
|
'subevent_mode': self.subevent_mode,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def is_available_by_time(self, now_dt=None) -> bool:
|
||||||
|
now_dt = now_dt or now()
|
||||||
|
if self.available_from and self.available_from > now_dt:
|
||||||
|
return False
|
||||||
|
if self.available_until and self.available_until < now_dt:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def _apply_min_value(self, positions, idx_group, result):
|
def _apply_min_value(self, positions, idx_group, result):
|
||||||
if self.condition_min_value and sum(positions[idx][2] for idx in idx_group) < self.condition_min_value:
|
if self.condition_min_value and sum(positions[idx][2] for idx in idx_group) < self.condition_min_value:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user