mirror of
https://github.com/pretix/pretix.git
synced 2026-08-15 11:36:27 +00:00
adapt allow_ticket_download signal
This commit is contained in:
@@ -44,7 +44,7 @@ from datetime import datetime, time, timedelta
|
||||
from decimal import Decimal
|
||||
from functools import reduce
|
||||
from time import sleep
|
||||
from typing import Any, Dict, List, Union
|
||||
from typing import Any, Dict, List, Union, Iterable
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import dateutil
|
||||
@@ -79,7 +79,7 @@ from pretix.base.i18n import language
|
||||
from pretix.base.models import Customer, User
|
||||
from pretix.base.reldate import RelativeDateWrapper
|
||||
from pretix.base.settings import PERSON_NAME_SCHEMES
|
||||
from pretix.base.signals import order_gracefully_delete
|
||||
from pretix.base.signals import order_gracefully_delete, allow_ticket_download
|
||||
|
||||
from ...helpers import OF_SELF
|
||||
from ...helpers.countries import CachedCountries, FastCountryField
|
||||
@@ -1200,6 +1200,16 @@ class Order(LockModel, LoggedModel):
|
||||
_transactions_mark_order_clean(self.pk)
|
||||
return create
|
||||
|
||||
@property
|
||||
def plugins_allow_ticket_download(self):
|
||||
signal_response = allow_ticket_download.send(self.event, order=self)
|
||||
if all([r == True for rr, r in signal_response]):
|
||||
return True
|
||||
elif any([r == False for rr, r in signal_response]):
|
||||
return False
|
||||
else:
|
||||
return set.intersection(*[set(r) for rr, r in signal_response if isinstance(r, Iterable)])
|
||||
|
||||
|
||||
def answerfile_name(instance, filename: str) -> str:
|
||||
secret = get_random_string(length=32, allowed_chars=string.ascii_letters + string.digits)
|
||||
|
||||
@@ -1408,7 +1408,7 @@ def send_download_reminders(sender, **kwargs):
|
||||
if o.download_reminder_sent:
|
||||
# Race condition
|
||||
continue
|
||||
if not all([r for rr, r in allow_ticket_download.send(event, order=o)]):
|
||||
if not o.plugins_allow_ticket_download:
|
||||
continue
|
||||
|
||||
if not o.ticket_download_available:
|
||||
|
||||
@@ -124,7 +124,7 @@ def preview(event: int, provider: str):
|
||||
|
||||
|
||||
def get_tickets_for_order(order, base_position=None):
|
||||
can_download = all([r for rr, r in allow_ticket_download.send(order.event, order=order)])
|
||||
can_download = order.plugins_allow_ticket_download
|
||||
if not can_download:
|
||||
return []
|
||||
if not order.ticket_download_available:
|
||||
|
||||
@@ -646,7 +646,7 @@ allow_ticket_download = EventPluginSignal()
|
||||
Arguments: ``order``
|
||||
|
||||
This signal is sent out to check if tickets for an order can be downloaded. If any receiver returns false,
|
||||
a download will not be offered.
|
||||
a download will not be offered. If a receiver returns a list of OrderPositions, only those will be downloadable.
|
||||
|
||||
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
@@ -177,7 +177,7 @@ class TicketPageMixin:
|
||||
|
||||
ctx['order'] = self.order
|
||||
|
||||
can_download = all([r for rr, r in allow_ticket_download.send(self.request.event, order=self.order)])
|
||||
can_download = self.order.plugins_allow_ticket_download
|
||||
ctx['plugins_allow_ticket_download'] = can_download
|
||||
if self.request.event.settings.ticket_download_date:
|
||||
ctx['ticket_download_date'] = self.order.ticket_download_date
|
||||
@@ -1048,7 +1048,7 @@ class OrderDownloadMixin:
|
||||
|
||||
@cached_property
|
||||
def output(self):
|
||||
if not all([r for rr, r in allow_ticket_download.send(self.request.event, order=self.order)]):
|
||||
if not self.order.plugins_allow_ticket_download:
|
||||
return None
|
||||
responses = register_ticket_outputs.send(self.request.event)
|
||||
for receiver, response in responses:
|
||||
|
||||
Reference in New Issue
Block a user