forked from CGM_Public/pretix_original
Add last order modification time as an email placeholder (#2761)
* Add last order modification time as an email placeholder * Update src/pretix/base/email.py Co-authored-by: Richard Schreiber <wiffbi@gmail.com> Co-authored-by: Richard Schreiber <wiffbi@gmail.com>
This commit is contained in:
@@ -43,6 +43,7 @@ from pretix.base.i18n import (
|
|||||||
LazyCurrencyNumber, LazyDate, LazyExpiresDate, LazyNumber,
|
LazyCurrencyNumber, LazyDate, LazyExpiresDate, LazyNumber,
|
||||||
)
|
)
|
||||||
from pretix.base.models import Event
|
from pretix.base.models import Event
|
||||||
|
from pretix.base.reldate import RelativeDateWrapper
|
||||||
from pretix.base.settings import PERSON_NAME_SCHEMES
|
from pretix.base.settings import PERSON_NAME_SCHEMES
|
||||||
from pretix.base.signals import (
|
from pretix.base.signals import (
|
||||||
register_html_mail_renderers, register_mail_placeholders,
|
register_html_mail_renderers, register_mail_placeholders,
|
||||||
@@ -469,6 +470,19 @@ def base_placeholders(sender, **kwargs):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SimpleFunctionalMailTextPlaceholder(
|
||||||
|
'order_modification_deadline_date_and_time', ['order', 'event'],
|
||||||
|
lambda order, event:
|
||||||
|
date_format(order.modify_deadline.astimezone(event.timezone), 'SHORT_DATETIME_FORMAT')
|
||||||
|
if order.modify_deadline
|
||||||
|
else '',
|
||||||
|
lambda event: date_format(
|
||||||
|
event.settings.get(
|
||||||
|
'last_order_modification_date', as_type=RelativeDateWrapper
|
||||||
|
).datetime(event).astimezone(event.timezone),
|
||||||
|
'SHORT_DATETIME_FORMAT'
|
||||||
|
) if event.settings.get('last_order_modification_date') else '',
|
||||||
|
),
|
||||||
SimpleFunctionalMailTextPlaceholder(
|
SimpleFunctionalMailTextPlaceholder(
|
||||||
'event_location', ['event_or_subevent'], lambda event_or_subevent: str(event_or_subevent.location or ''),
|
'event_location', ['event_or_subevent'], lambda event_or_subevent: str(event_or_subevent.location or ''),
|
||||||
lambda event: str(event.location or ''),
|
lambda event: str(event.location or ''),
|
||||||
|
|||||||
@@ -746,6 +746,19 @@ class Order(LockModel, LoggedModel):
|
|||||||
length += 1
|
length += 1
|
||||||
iteration = 0
|
iteration = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def modify_deadline(self):
|
||||||
|
modify_deadline = self.event.settings.get('last_order_modification_date', as_type=RelativeDateWrapper)
|
||||||
|
if self.event.has_subevents and modify_deadline:
|
||||||
|
dates = [
|
||||||
|
modify_deadline.datetime(se)
|
||||||
|
for se in self.event.subevents.filter(id__in=self.positions.values_list('subevent', flat=True))
|
||||||
|
]
|
||||||
|
return min(dates) if dates else None
|
||||||
|
elif modify_deadline:
|
||||||
|
return modify_deadline.datetime(self.event)
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_modify_answers(self) -> bool:
|
def can_modify_answers(self) -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -758,16 +771,7 @@ class Order(LockModel, LoggedModel):
|
|||||||
if self.status not in (Order.STATUS_PENDING, Order.STATUS_PAID, Order.STATUS_EXPIRED):
|
if self.status not in (Order.STATUS_PENDING, Order.STATUS_PAID, Order.STATUS_EXPIRED):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
modify_deadline = self.event.settings.get('last_order_modification_date', as_type=RelativeDateWrapper)
|
modify_deadline = self.modify_deadline
|
||||||
if self.event.has_subevents and modify_deadline:
|
|
||||||
dates = [
|
|
||||||
modify_deadline.datetime(se)
|
|
||||||
for se in self.event.subevents.filter(id__in=self.positions.values_list('subevent', flat=True))
|
|
||||||
]
|
|
||||||
modify_deadline = min(dates) if dates else None
|
|
||||||
elif modify_deadline:
|
|
||||||
modify_deadline = modify_deadline.datetime(self.event)
|
|
||||||
|
|
||||||
if modify_deadline is not None and now() > modify_deadline:
|
if modify_deadline is not None and now() > modify_deadline:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user