mirror of
https://github.com/pretix/pretix.git
synced 2026-11-20 02:56:03 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b80e77b10 |
No files matched your search
+1
-1
@@ -91,7 +91,7 @@ dependencies = [
|
||||
"redis==7.4.*",
|
||||
"reportlab==5.1.*",
|
||||
"requests==2.34.*",
|
||||
"sentry-sdk==2.75.*",
|
||||
"sentry-sdk==2.71.*",
|
||||
"sepaxml==2.7.*",
|
||||
"stripe==7.9.*",
|
||||
"text-unidecode==1.*",
|
||||
|
||||
@@ -33,7 +33,7 @@ from rest_framework import status
|
||||
|
||||
from pretix.api.models import ApiCall
|
||||
from pretix.base.models import Organizer
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers.database import LOCK_SELF_NO_KEY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -60,7 +60,7 @@ class IdempotencyMiddleware:
|
||||
idempotency_key = request.headers.get('X-Idempotency-Key', '')
|
||||
|
||||
with transaction.atomic(durable=True):
|
||||
call, created = ApiCall.objects.select_for_update(of=OF_SELF).get_or_create(
|
||||
call, created = ApiCall.objects.select_for_update(**LOCK_SELF_NO_KEY).get_or_create(
|
||||
auth_hash=auth_hash,
|
||||
idempotency_key=idempotency_key,
|
||||
defaults={
|
||||
|
||||
@@ -75,7 +75,7 @@ from pretix.base.services.checkin import (
|
||||
)
|
||||
from pretix.base.services.media import perform_media_exchange
|
||||
from pretix.base.signals import checkin_annulled
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
with scopes_disabled():
|
||||
class CheckinListFilter(FilterSet):
|
||||
@@ -1184,14 +1184,14 @@ class CheckinRPCAnnulView(views.APIView):
|
||||
if isinstance(request.auth, Device):
|
||||
qs = qs.filter(device=request.auth)
|
||||
ci = qs.select_for_update(
|
||||
of=OF_SELF,
|
||||
**LOCK_SELF_NO_KEY,
|
||||
).select_related("position", "position__order", "position__order__event").get(
|
||||
list__in=s.validated_data['lists'],
|
||||
nonce=s.validated_data['nonce'],
|
||||
)
|
||||
if connection.features.has_select_for_update_of and ci.position_id:
|
||||
# Lock position as well, can't do it with of= above because relation is nullable
|
||||
OrderPosition.objects.select_for_update(of=OF_SELF).get(pk=ci.position_id)
|
||||
OrderPosition.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=ci.position_id)
|
||||
|
||||
if not ci.successful or not ci.position:
|
||||
raise ValidationError("Cannot annul an unsuccessful checkin")
|
||||
|
||||
@@ -43,7 +43,7 @@ from pretix.base.models import (
|
||||
ReusableMedium,
|
||||
)
|
||||
from pretix.base.models.orders import PrintLog
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.dicts import merge_dicts
|
||||
|
||||
with scopes_disabled():
|
||||
@@ -119,7 +119,7 @@ class ReusableMediaViewSet(viewsets.ModelViewSet):
|
||||
|
||||
@transaction.atomic()
|
||||
def perform_update(self, serializer):
|
||||
rm = ReusableMedium.objects.select_for_update(of=OF_SELF).get(pk=self.get_object().pk)
|
||||
rm = ReusableMedium.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.get_object().pk)
|
||||
prev_linked_ops_pks = list(rm.linked_orderpositions.values_list("pk", flat=True))
|
||||
inst = serializer.save(identifier=serializer.instance.identifier, type=serializer.instance.type)
|
||||
linked_ops_pks = inst.linked_orderpositions.values_list("pk", flat=True)
|
||||
|
||||
@@ -102,7 +102,7 @@ from pretix.base.signals import (
|
||||
order_modified, order_paid, order_placed, register_ticket_outputs,
|
||||
)
|
||||
from pretix.control.signals import order_search_filter_q
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -600,7 +600,7 @@ class EventOrderViewSet(OrderViewSetMixin, viewsets.ModelViewSet):
|
||||
@transaction.atomic()
|
||||
def create_invoice(self, request, **kwargs):
|
||||
order = self.get_object()
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=order.pk)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=order.pk)
|
||||
has_inv = order.invoices.exists() and not (
|
||||
order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and order.invoices.filter(is_cancellation=True).count() >= order.invoices.filter(is_cancellation=False).count()
|
||||
@@ -2026,7 +2026,7 @@ class InvoiceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
raise PermissionDenied('The invoice file is no longer stored on the server.')
|
||||
|
||||
with transaction.atomic(durable=True):
|
||||
invoice = Invoice.objects.select_for_update(of=OF_SELF).get(pk=invoice.pk)
|
||||
invoice = Invoice.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=invoice.pk)
|
||||
|
||||
if invoice.transmission_status == Invoice.TRANSMISSION_STATUS_INFLIGHT:
|
||||
raise CurrentlyInflightException()
|
||||
@@ -2080,7 +2080,7 @@ class InvoiceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
elif inv.shredded:
|
||||
raise PermissionDenied('The invoice file is no longer stored on the server.')
|
||||
else:
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=inv.order_id)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=inv.order_id)
|
||||
c = generate_cancellation(inv)
|
||||
if invoice_qualified(order):
|
||||
inv = generate_invoice(order)
|
||||
|
||||
@@ -58,7 +58,7 @@ from pretix.base.models import (
|
||||
from pretix.base.plugins import (
|
||||
PLUGIN_LEVEL_EVENT, PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID,
|
||||
)
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.dicts import merge_dicts
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ class GiftCardViewSet(viewsets.ModelViewSet):
|
||||
def perform_update(self, serializer):
|
||||
if 'include_accepted' in self.request.GET:
|
||||
raise PermissionDenied("Accepted gift cards cannot be updated, use transact instead.")
|
||||
GiftCard.objects.select_for_update(of=OF_SELF).get(pk=self.get_object().pk)
|
||||
GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.get_object().pk)
|
||||
|
||||
value = serializer.validated_data.pop('value', None)
|
||||
|
||||
@@ -310,7 +310,7 @@ class GiftCardViewSet(viewsets.ModelViewSet):
|
||||
@action(detail=True, methods=["POST"])
|
||||
@transaction.atomic()
|
||||
def transact(self, request, **kwargs):
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=self.get_object().pk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.get_object().pk)
|
||||
value = serializers.DecimalField(max_digits=13, decimal_places=2).to_internal_value(
|
||||
request.data.get('value')
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ from pretix.base.models import LogEntry
|
||||
from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask
|
||||
from pretix.base.signals import periodic_task
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.celery import get_task_priority
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -678,7 +678,7 @@ def manually_retry_all_calls(webhook_id: int):
|
||||
with scope(organizer=webhook.organizer), transaction.atomic():
|
||||
for whcr in webhook.retries.select_for_update(
|
||||
skip_locked=connection.features.has_select_for_update_skip_locked,
|
||||
of=OF_SELF
|
||||
**LOCK_SELF_NO_KEY
|
||||
):
|
||||
send_webhook.apply_async(
|
||||
args=(whcr.logentry_id, whcr.action_type, whcr.webhook_id, whcr.retry_count),
|
||||
@@ -692,7 +692,7 @@ def schedule_webhook_retries_on_celery(sender, **kwargs):
|
||||
with transaction.atomic():
|
||||
for whcr in WebHookCallRetry.objects.select_for_update(
|
||||
skip_locked=connection.features.has_select_for_update_skip_locked,
|
||||
of=OF_SELF
|
||||
**LOCK_SELF_NO_KEY
|
||||
).filter(retry_not_before__lt=now()):
|
||||
send_webhook.apply_async(
|
||||
args=(whcr.logentry_id, whcr.action_type, whcr.webhook_id, whcr.retry_count),
|
||||
|
||||
@@ -40,7 +40,7 @@ from pretix.base.i18n import language
|
||||
from pretix.base.logentrytype_registry import make_link
|
||||
from pretix.base.models.datasync import OrderSyncQueue, OrderSyncResult
|
||||
from pretix.base.signals import PluginAwareRegistry
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -199,7 +199,7 @@ class OutboundSyncProvider:
|
||||
try:
|
||||
sq = (
|
||||
OrderSyncQueue.objects
|
||||
.select_for_update(of=OF_SELF, nowait=True)
|
||||
.select_for_update(**LOCK_SELF_NO_KEY, nowait=True)
|
||||
.select_related("order")
|
||||
.get(pk=queue_item.pk)
|
||||
)
|
||||
|
||||
@@ -85,7 +85,7 @@ from pretix.base.settings import PERSON_NAME_SCHEMES, ROUNDING_MODES
|
||||
from pretix.base.signals import allow_ticket_download, order_gracefully_delete
|
||||
from pretix.base.timemachine import time_machine_now
|
||||
|
||||
from ...helpers import OF_SELF
|
||||
from ...helpers import LOCK_SELF_NO_KEY
|
||||
from ...helpers.countries import CachedCountries, FastCountryField
|
||||
from ...helpers.models import NormalizedDecimalField
|
||||
from ...helpers.names import build_name
|
||||
@@ -1859,7 +1859,7 @@ class OrderPayment(models.Model):
|
||||
:param send_mail: Whether an email should be sent to the user about this event (default: ``True``).
|
||||
"""
|
||||
with transaction.atomic():
|
||||
locked_instance = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=self.pk)
|
||||
locked_instance = OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.pk)
|
||||
if locked_instance.state in (
|
||||
OrderPayment.PAYMENT_STATE_CONFIRMED,
|
||||
OrderPayment.PAYMENT_STATE_FAILED,
|
||||
@@ -1928,7 +1928,7 @@ class OrderPayment(models.Model):
|
||||
:raises Quota.QuotaExceededException: if the quota is exceeded and ``force`` is ``False``
|
||||
"""
|
||||
with transaction.atomic():
|
||||
locked_instance = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=self.pk)
|
||||
locked_instance = OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.pk)
|
||||
if locked_instance.state == self.PAYMENT_STATE_CONFIRMED:
|
||||
# Race condition detected, this payment is already confirmed
|
||||
logger.info('Confirmed payment {} but ignored due to likely race condition.'.format(
|
||||
|
||||
@@ -35,7 +35,7 @@ from pretix.base.email import get_email_context
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import User, Voucher
|
||||
from pretix.base.services.mail import mail
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
from ...helpers.names import build_name
|
||||
from .base import LoggedModel
|
||||
@@ -191,7 +191,7 @@ class WaitingListEntry(LoggedModel):
|
||||
raise WaitingListException(_('This entry is anonymized and can no longer be used.'))
|
||||
|
||||
with transaction.atomic():
|
||||
locked_wle = WaitingListEntry.objects.select_for_update(of=OF_SELF).get(pk=self.pk)
|
||||
locked_wle = WaitingListEntry.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.pk)
|
||||
locked_wle.event = event
|
||||
if locked_wle.voucher:
|
||||
raise WaitingListException(_('A voucher has already been sent to this person.'))
|
||||
|
||||
@@ -67,7 +67,7 @@ from pretix.base.signals import register_payment_providers
|
||||
from pretix.base.templatetags.money import money_filter
|
||||
from pretix.base.templatetags.rich_text import rich_text
|
||||
from pretix.base.timemachine import time_machine_now
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.countries import CachedCountries
|
||||
from pretix.helpers.format import format_map
|
||||
from pretix.helpers.money import DecimalTextInput
|
||||
@@ -1645,7 +1645,7 @@ class GiftCardPayment(BasePaymentProvider):
|
||||
try:
|
||||
with transaction.atomic():
|
||||
try:
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=gcpk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=gcpk)
|
||||
except GiftCard.DoesNotExist:
|
||||
raise PaymentException(_("This gift card does not support this currency."))
|
||||
if gc.currency != self.event.currency: # noqa - just a safeguard
|
||||
|
||||
@@ -45,7 +45,7 @@ from pretix.base.services.tasks import ProfiledEventTask
|
||||
from pretix.base.services.tax import split_fee_for_taxes
|
||||
from pretix.base.templatetags.money import money_filter
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -286,7 +286,7 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
|
||||
if dry_run:
|
||||
o = event.orders.get(pk=o)
|
||||
else:
|
||||
o = event.orders.select_for_update(of=OF_SELF).get(pk=o)
|
||||
o = event.orders.select_for_update(**LOCK_SELF_NO_KEY).get(pk=o)
|
||||
total = Decimal('0.00')
|
||||
fee = Decimal('0.00')
|
||||
positions = []
|
||||
|
||||
@@ -58,7 +58,7 @@ from pretix.base.models import (
|
||||
OrderPosition, QuestionOption,
|
||||
)
|
||||
from pretix.base.signals import checkin_created, periodic_task
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.database import conditional_atomic
|
||||
from pretix.helpers.jsonlogic import Logic
|
||||
from pretix.helpers.jsonlogic_boolalg import convert_to_dnf
|
||||
@@ -1049,7 +1049,7 @@ def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict,
|
||||
# Lock order positions, if it is an entry. We don't need it for exits, as a race condition wouldn't be problematic
|
||||
opqs = OrderPosition.all.select_related("order", "item")
|
||||
if type != Checkin.TYPE_EXIT and not simulate:
|
||||
opqs = opqs.select_for_update(of=OF_SELF)
|
||||
opqs = opqs.select_for_update(**LOCK_SELF_NO_KEY)
|
||||
op = opqs.get(pk=op.pk)
|
||||
|
||||
if not clist.all_products and op.item_id not in [i.pk for i in clist.limit_products.all()]:
|
||||
|
||||
@@ -50,7 +50,7 @@ from pretix.base.signals import (
|
||||
periodic_task, register_data_exporters, register_multievent_data_exporters,
|
||||
)
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers import OF_SELF, repeatable_reads_transaction
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY, repeatable_reads_transaction
|
||||
from pretix.helpers.urls import mainreverse_absolute
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -501,7 +501,7 @@ def run_scheduled_exports(sender, **kwargs):
|
||||
qs = ScheduledEventExport.objects.filter(
|
||||
schedule_next_run__lt=now(),
|
||||
error_counter__lt=5,
|
||||
).select_for_update(skip_locked=connection.features.has_select_for_update_skip_locked, of=OF_SELF).select_related('event')
|
||||
).select_for_update(skip_locked=connection.features.has_select_for_update_skip_locked, **LOCK_SELF_NO_KEY).select_related('event')
|
||||
for s in qs:
|
||||
scheduled_event_export.apply_async(kwargs={
|
||||
'event': s.event_id,
|
||||
@@ -512,7 +512,7 @@ def run_scheduled_exports(sender, **kwargs):
|
||||
qs = ScheduledOrganizerExport.objects.filter(
|
||||
schedule_next_run__lt=now(),
|
||||
error_counter__lt=5,
|
||||
).select_for_update(skip_locked=connection.features.has_select_for_update_skip_locked, of=OF_SELF).select_related('organizer')
|
||||
).select_for_update(skip_locked=connection.features.has_select_for_update_skip_locked, **LOCK_SELF_NO_KEY).select_related('organizer')
|
||||
for s in qs:
|
||||
scheduled_organizer_export.apply_async(kwargs={
|
||||
'organizer': s.organizer_id,
|
||||
|
||||
@@ -67,7 +67,7 @@ from pretix.base.signals import (
|
||||
build_invoice_data, invoice_line_text, periodic_task,
|
||||
)
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers.database import OF_SELF, rolledback_transaction
|
||||
from pretix.helpers.database import LOCK_SELF_NO_KEY, rolledback_transaction
|
||||
from pretix.helpers.models import modelcopy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -688,7 +688,7 @@ def send_invoices_to_organizer(sender, **kwargs):
|
||||
with transaction.atomic():
|
||||
qs = Invoice.objects.filter(
|
||||
sent_to_organizer__isnull=True
|
||||
).prefetch_related('event', 'order').select_for_update(of=OF_SELF, skip_locked=connection.features.has_select_for_update_skip_locked)
|
||||
).prefetch_related('event', 'order').select_for_update(**LOCK_SELF_NO_KEY, skip_locked=connection.features.has_select_for_update_skip_locked)
|
||||
for i in qs[:batch_size]:
|
||||
if i.event.settings.invoice_email_organizer:
|
||||
with language(i.event.settings.locale):
|
||||
@@ -724,7 +724,7 @@ def retry_stuck_invoices(sender, **kwargs):
|
||||
transmission_status=Invoice.TRANSMISSION_STATUS_INFLIGHT,
|
||||
transmission_date__lte=now() - timedelta(hours=48),
|
||||
).select_for_update(
|
||||
of=OF_SELF, skip_locked=connection.features.has_select_for_update_skip_locked
|
||||
**LOCK_SELF_NO_KEY, skip_locked=connection.features.has_select_for_update_skip_locked
|
||||
)
|
||||
batch_size = 5000
|
||||
for invoice in qs[:batch_size]:
|
||||
@@ -749,7 +749,7 @@ def send_pending_invoices(sender, **kwargs):
|
||||
transmission_status=Invoice.TRANSMISSION_STATUS_PENDING,
|
||||
created__lte=now() - timedelta(minutes=15),
|
||||
).select_for_update(
|
||||
of=OF_SELF, skip_locked=connection.features.has_select_for_update_skip_locked
|
||||
**LOCK_SELF_NO_KEY, skip_locked=connection.features.has_select_for_update_skip_locked
|
||||
)
|
||||
batch_size = 5000
|
||||
for invoice in qs[:batch_size]:
|
||||
@@ -760,7 +760,7 @@ def send_pending_invoices(sender, **kwargs):
|
||||
def transmit_invoice(sender, invoice_id, allow_retransmission=True, **kwargs):
|
||||
with transaction.atomic(durable='tests.testdummy' not in settings.INSTALLED_APPS):
|
||||
# We need durable=True for transactional correctness, but can't have it during tests
|
||||
invoice = Invoice.objects.select_for_update(of=OF_SELF).get(pk=invoice_id)
|
||||
invoice = Invoice.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=invoice_id)
|
||||
|
||||
if invoice.transmission_status == Invoice.TRANSMISSION_STATUS_INFLIGHT:
|
||||
logger.info(f"Did not transmit invoice {invoice.pk} due to being in inflight state.")
|
||||
|
||||
@@ -80,7 +80,7 @@ from pretix.base.signals import (
|
||||
email_filter, global_email_filter, periodic_task,
|
||||
)
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.format import (
|
||||
FormattedString, PlainHtmlAlternativeString, SafeFormatter, format_map,
|
||||
)
|
||||
@@ -412,7 +412,7 @@ def mail_send_task(self, **kwargs) -> bool:
|
||||
|
||||
with transaction.atomic():
|
||||
try:
|
||||
outgoing_mail = OutgoingMail.objects.select_for_update(of=OF_SELF).get(pk=outgoing_mail)
|
||||
outgoing_mail = OutgoingMail.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=outgoing_mail)
|
||||
except OutgoingMail.DoesNotExist:
|
||||
logger.info(f"Ignoring job for non existing email {outgoing_mail}")
|
||||
return False
|
||||
@@ -1107,7 +1107,7 @@ def retry_stuck_inflight_mails(sender, **kwargs):
|
||||
for m in OutgoingMail.objects.filter(
|
||||
status=OutgoingMail.STATUS_INFLIGHT,
|
||||
inflight_since__lt=now() - timedelta(hours=1),
|
||||
).select_for_update(of=OF_SELF, skip_locked=connection.features.has_select_for_update_skip_locked):
|
||||
).select_for_update(**LOCK_SELF_NO_KEY, skip_locked=connection.features.has_select_for_update_skip_locked):
|
||||
m.status = OutgoingMail.STATUS_QUEUED
|
||||
m.save()
|
||||
mail_send_task.apply_async(kwargs={"outgoing_mail": m.pk})
|
||||
|
||||
@@ -33,7 +33,7 @@ from pretix.base.models import (
|
||||
OrderPosition, SubEvent,
|
||||
)
|
||||
from pretix.base.timemachine import time_machine_now
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
|
||||
def membership_validity(item: Item, subevent: Optional[SubEvent], event: Event):
|
||||
@@ -125,7 +125,7 @@ def validate_memberships_in_order(customer: Customer, positions: List[AbstractPo
|
||||
base_qs = Membership.objects.with_usages(ignored_order=ignored_order)
|
||||
|
||||
if lock:
|
||||
base_qs = base_qs.select_for_update(of=OF_SELF)
|
||||
base_qs = base_qs.select_for_update(**LOCK_SELF_NO_KEY)
|
||||
|
||||
membership_cache = base_qs\
|
||||
.select_related('membership_type')\
|
||||
|
||||
@@ -107,7 +107,7 @@ from pretix.base.signals import (
|
||||
)
|
||||
from pretix.base.timemachine import time_machine_now, time_machine_now_assigned
|
||||
from pretix.celery_app import app
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.models import modelcopy
|
||||
from pretix.helpers.periodic import minimum_interval
|
||||
from pretix.presale.productlist import prepare_item_list_for_shop
|
||||
@@ -246,7 +246,7 @@ def reactivate_order(order: Order, force: bool=False, user: User=None, auth=None
|
||||
Voucher.objects.filter(pk=position.voucher.pk).update(redeemed=Greatest(0, F('redeemed') + 1))
|
||||
|
||||
for gc in position.issued_gift_cards.all():
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=gc.pk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=gc.pk)
|
||||
gc.transactions.create(value=position.price, order=order, acceptor=order.event.organizer)
|
||||
gc.log_action(
|
||||
action='pretix.giftcards.transaction.manual',
|
||||
@@ -524,7 +524,7 @@ def _cancel_order(order, user=None, send_mail: bool=True, api_token=None, device
|
||||
# If new actions are added to this function, make sure to add the reverse operation to reactivate_order()
|
||||
with transaction.atomic():
|
||||
if isinstance(order, int):
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=order)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=order)
|
||||
if isinstance(user, int):
|
||||
user = User.objects.get(pk=user)
|
||||
if isinstance(api_token, int):
|
||||
@@ -550,7 +550,7 @@ def _cancel_order(order, user=None, send_mail: bool=True, api_token=None, device
|
||||
|
||||
for position in order.positions.all():
|
||||
for gc in position.issued_gift_cards.all():
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=gc.pk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=gc.pk)
|
||||
if gc.value < position.price:
|
||||
raise OrderError(
|
||||
_('This order can not be canceled since the gift card {card} purchased in '
|
||||
@@ -1489,7 +1489,7 @@ def send_expiry_warnings(sender, **kwargs):
|
||||
|
||||
if days and (o.expires - today).days <= days:
|
||||
with transaction.atomic():
|
||||
o = Order.objects.select_related('event').select_for_update(of=OF_SELF).get(pk=o.pk)
|
||||
o = Order.objects.select_related('event').select_for_update(**LOCK_SELF_NO_KEY).get(pk=o.pk)
|
||||
if o.status != Order.STATUS_PENDING or o.expiry_reminder_sent:
|
||||
# Race condition
|
||||
continue
|
||||
@@ -1574,7 +1574,7 @@ def send_download_reminders(sender, **kwargs):
|
||||
continue
|
||||
|
||||
with transaction.atomic():
|
||||
o = Order.objects.select_for_update(of=OF_SELF).get(pk=o.pk)
|
||||
o = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=o.pk)
|
||||
if o.download_reminder_sent:
|
||||
# Race condition
|
||||
continue
|
||||
@@ -2560,7 +2560,7 @@ class OrderChangeManager:
|
||||
elif isinstance(op, self.CancelOperation):
|
||||
position = position_cache.setdefault(op.position.pk, op.position)
|
||||
for gc in position.issued_gift_cards.all():
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=gc.pk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=gc.pk)
|
||||
if gc.value < position.price:
|
||||
raise OrderError(_(
|
||||
'A position can not be canceled since the gift card {card} purchased in this order has '
|
||||
@@ -2587,7 +2587,7 @@ class OrderChangeManager:
|
||||
for opa in position.addons.all():
|
||||
opa = position_cache.setdefault(opa.pk, opa)
|
||||
for gc in opa.issued_gift_cards.all():
|
||||
gc = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=gc.pk)
|
||||
gc = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=gc.pk)
|
||||
if gc.value < opa.position.price:
|
||||
raise OrderError(_(
|
||||
'A position can not be canceled since the gift card {card} purchased in this order has '
|
||||
@@ -3162,7 +3162,7 @@ class OrderChangeManager:
|
||||
self._check_order_size()
|
||||
|
||||
with transaction.atomic():
|
||||
locked_instance = Order.objects.select_for_update(of=OF_SELF).get(pk=self.order.pk)
|
||||
locked_instance = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.order.pk)
|
||||
if locked_instance.last_modified != self.order.last_modified:
|
||||
raise OrderError(error_messages['race_condition'])
|
||||
|
||||
@@ -3466,9 +3466,9 @@ def change_payment_provider(order: Order, payment_provider, amount=None, new_pay
|
||||
|
||||
open_payment = None
|
||||
if new_payment:
|
||||
lp = order.payments.select_for_update(of=OF_SELF).exclude(pk=new_payment.pk).last()
|
||||
lp = order.payments.select_for_update(**LOCK_SELF_NO_KEY).exclude(pk=new_payment.pk).last()
|
||||
else:
|
||||
lp = order.payments.select_for_update(of=OF_SELF).last()
|
||||
lp = order.payments.select_for_update(**LOCK_SELF_NO_KEY).last()
|
||||
|
||||
if lp and lp.state in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED):
|
||||
open_payment = lp
|
||||
@@ -3515,7 +3515,7 @@ def change_payment_provider(order: Order, payment_provider, amount=None, new_pay
|
||||
new_invoice = None
|
||||
if recreate_invoices:
|
||||
# Lock to prevent duplicate invoice creation
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=order.pk)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=order.pk)
|
||||
|
||||
i = order.invoices.filter(is_cancellation=False).last()
|
||||
has_active_invoice = i and not i.canceled
|
||||
|
||||
@@ -79,8 +79,8 @@ class WaitingListEntryEditForm(I18nModelForm):
|
||||
self.fields['name_parts'] = NamePartsFormField(
|
||||
max_length=255,
|
||||
required=self.event.settings.waiting_list_names_required,
|
||||
scheme=self.event.settings.name_scheme,
|
||||
titles=self.event.settings.name_scheme_titles,
|
||||
scheme=self.event.organizer.settings.name_scheme,
|
||||
titles=self.event.organizer.settings.name_scheme_titles,
|
||||
label=_('Name'),
|
||||
)
|
||||
else:
|
||||
|
||||
@@ -66,7 +66,7 @@ from pretix.base.forms.auth import (
|
||||
)
|
||||
from pretix.base.metrics import pretix_failed_logins, pretix_successful_logins
|
||||
from pretix.base.models import TeamInvite, U2FDevice, User, WebAuthnDevice
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.http import get_client_ip, redirect_to_url
|
||||
from pretix.helpers.ratelimit import rate_limit, rate_limit_reset
|
||||
from pretix.helpers.security import handle_login_source, session_login
|
||||
@@ -401,7 +401,7 @@ class Recover(TemplateView):
|
||||
with transaction.atomic():
|
||||
# Check token in transaction to prevent race condition
|
||||
try:
|
||||
user = User.objects.select_for_update(of=OF_SELF).get(id=self.request.GET.get('id'), auth_backend='native')
|
||||
user = User.objects.select_for_update(**LOCK_SELF_NO_KEY).get(id=self.request.GET.get('id'), auth_backend='native')
|
||||
except User.DoesNotExist:
|
||||
return self.invalid('unknownuser')
|
||||
if not default_token_generator.check_token(user, self.request.GET.get('token')):
|
||||
|
||||
@@ -43,7 +43,7 @@ from pretix.control.permissions import (
|
||||
)
|
||||
from pretix.control.signals import order_info
|
||||
from pretix.control.views.orders import OrderView
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
|
||||
|
||||
@receiver(order_info, dispatch_uid="datasync_control_order_info")
|
||||
@@ -83,7 +83,7 @@ class ControlSyncJob(OrderView):
|
||||
elif self.request.POST.get("cancel_job"):
|
||||
with transaction.atomic():
|
||||
try:
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
job = self.order.queued_sync_jobs.select_for_update(**LOCK_SELF_NO_KEY).get(
|
||||
pk=self.request.POST.get("cancel_job")
|
||||
)
|
||||
except OrderSyncQueue.DoesNotExist:
|
||||
@@ -97,7 +97,7 @@ class ControlSyncJob(OrderView):
|
||||
elif self.request.POST.get("run_job_now"):
|
||||
with transaction.atomic():
|
||||
try:
|
||||
job = self.order.queued_sync_jobs.select_for_update(of=OF_SELF).get(
|
||||
job = self.order.queued_sync_jobs.select_for_update(**LOCK_SELF_NO_KEY).get(
|
||||
pk=self.request.POST.get("run_job_now")
|
||||
)
|
||||
except OrderSyncQueue.DoesNotExist:
|
||||
|
||||
@@ -135,7 +135,7 @@ from pretix.control.permissions import (
|
||||
)
|
||||
from pretix.control.signals import order_search_forms
|
||||
from pretix.control.views import PaginationMixin
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.compat import CompatDeleteView
|
||||
from pretix.helpers.format import SafeFormatter, format_map
|
||||
from pretix.helpers.hierarkey import clean_filename
|
||||
@@ -1161,7 +1161,7 @@ class OrderRefundView(OrderView):
|
||||
|
||||
@transaction.atomic()
|
||||
def perform_refund(self, comment, full_refund, payments):
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=self.order.pk)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.order.pk)
|
||||
|
||||
if self.request.POST.get("last_known_refund_id", "0") != str(self.order.refunds.aggregate(m=Max("id"))["m"] or 0):
|
||||
messages.error(self.request, _('The refund was prevented due to a refund already being processed at the '
|
||||
@@ -1477,7 +1477,7 @@ class OrderTransition(OrderView):
|
||||
@transaction.atomic()
|
||||
def post(self, request, *args, **kwargs):
|
||||
to = self.request.POST.get('status', '')
|
||||
self.order = Order.objects.select_for_update(of=OF_SELF).get(pk=self.order.pk)
|
||||
self.order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.order.pk)
|
||||
|
||||
if self.order.status in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and to == 'p' and self.mark_paid_form.is_valid():
|
||||
ps = self.mark_paid_form.cleaned_data['amount']
|
||||
@@ -1618,7 +1618,7 @@ class OrderInvoiceCreate(OrderView):
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
with transaction.atomic():
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=self.order.pk)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.order.pk)
|
||||
has_inv = order.invoices.exists() and not (
|
||||
order.status in (Order.STATUS_PAID, Order.STATUS_PENDING)
|
||||
and order.invoices.filter(is_cancellation=True).count() >= order.invoices.filter(is_cancellation=False).count()
|
||||
@@ -1727,7 +1727,7 @@ class OrderInvoiceRetransmit(OrderView):
|
||||
def post(self, *args, **kwargs):
|
||||
with transaction.atomic(durable=True):
|
||||
try:
|
||||
invoice = self.order.invoices.select_for_update(of=OF_SELF).get(pk=kwargs.get("id"))
|
||||
invoice = self.order.invoices.select_for_update(**LOCK_SELF_NO_KEY).get(pk=kwargs.get("id"))
|
||||
except Invoice.DoesNotExist:
|
||||
messages.error(self.request, _('Unknown invoice.'))
|
||||
return redirect(self.get_order_url())
|
||||
@@ -1757,7 +1757,7 @@ class OrderInvoiceReissue(OrderView):
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
with transaction.atomic():
|
||||
order = Order.objects.select_for_update(of=OF_SELF).get(pk=self.order.pk)
|
||||
order = Order.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.order.pk)
|
||||
try:
|
||||
inv = order.invoices.get(pk=kwargs.get('id'))
|
||||
except Invoice.DoesNotExist:
|
||||
|
||||
@@ -139,7 +139,7 @@ from pretix.control.permissions import (
|
||||
from pretix.control.signals import nav_organizer
|
||||
from pretix.control.views import LargeResultSetPaginator, PaginationMixin
|
||||
from pretix.control.views.mailsetup import MailSettingsSetupView
|
||||
from pretix.helpers import OF_SELF, GroupConcat
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY, GroupConcat
|
||||
from pretix.helpers.compat import CompatDeleteView
|
||||
from pretix.helpers.dicts import merge_dicts
|
||||
from pretix.helpers.format import SafeFormatter, format_map
|
||||
@@ -1795,7 +1795,7 @@ class GiftCardDetailView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMi
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not request.user.has_organizer_permission(request.organizer, "organizer.giftcards:write", request=request):
|
||||
raise PermissionDenied()
|
||||
self.object = GiftCard.objects.select_for_update(of=OF_SELF).get(pk=self.get_object().pk)
|
||||
self.object = GiftCard.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.get_object().pk)
|
||||
if 'revert' in request.POST:
|
||||
t = get_object_or_404(self.object.transactions.all(), pk=request.POST.get('revert'), order__isnull=False)
|
||||
if self.object.value - t.value < Decimal('0.00'):
|
||||
|
||||
@@ -29,7 +29,6 @@ from django.db.models import (
|
||||
Aggregate, Expression, F, Field, Func, IntegerField, JSONField, Lookup,
|
||||
OrderBy, Value,
|
||||
)
|
||||
from django.utils.functional import lazy
|
||||
|
||||
|
||||
class DummyRollbackException(Exception):
|
||||
@@ -213,9 +212,12 @@ class PostgresWindowFrame(Expression):
|
||||
}
|
||||
|
||||
|
||||
# This is a short-hand for .select_for_update(of=("self,")), that falls back gracefully on databases that don't support
|
||||
# the SELECT FOR UPDATE OF ... query.
|
||||
OF_SELF = lazy(lambda: ("self",) if connection.features.has_select_for_update_of else (), tuple)()
|
||||
# OF_SELF is kept for backwards-compatibility. Since we do not need MySQL any more, you can just use `of=("self",)`
|
||||
# SQLite will not fail, but just ignore it
|
||||
OF_SELF = ("self",)
|
||||
# Provided as a constant for convenience because `("self",)` is annoying to type and this way we can more easily update
|
||||
# things across the codebase if required
|
||||
LOCK_SELF_NO_KEY = {"of": OF_SELF, "no_key": True}
|
||||
|
||||
|
||||
def get_deterministic_ordering(model, ordering):
|
||||
|
||||
@@ -8,8 +8,8 @@ msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-10-28 10:48+0000\n"
|
||||
"PO-Revision-Date: 2026-11-19 18:00+0000\n"
|
||||
"Last-Translator: Tim <plicnetwork@gmail.com>\n"
|
||||
"PO-Revision-Date: 2026-10-29 17:00+0000\n"
|
||||
"Last-Translator: CVZ-es <damien.bremont@casadevelazquez.org>\n"
|
||||
"Language-Team: Spanish <https://translate.pretix.eu/projects/pretix/pretix/"
|
||||
"es/>\n"
|
||||
"Language: es\n"
|
||||
@@ -17,7 +17,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 2026.11.2\n"
|
||||
"X-Generator: Weblate 2026.10.1\n"
|
||||
|
||||
#: pretix/_base_settings.py
|
||||
msgid "English"
|
||||
@@ -29522,7 +29522,7 @@ msgstr ""
|
||||
"Le hemos reembolsado {amount} por su pedido.\n"
|
||||
"\n"
|
||||
"Puede utilizar el código de la tarjeta regalo {giftcard} para pagar futuras "
|
||||
"reservas.\n"
|
||||
"compras en nuestra tienda.\n"
|
||||
"\n"
|
||||
"El equipo de {event}"
|
||||
|
||||
|
||||
@@ -47,3 +47,6 @@ class Paypal2App(AppConfig):
|
||||
|
||||
def ready(self):
|
||||
from . import signals # NOQA
|
||||
|
||||
def is_available(self, event):
|
||||
return 'pretix.plugins.paypal' not in event.plugins.split(',')
|
||||
@@ -56,7 +56,7 @@ from pretix.base.forms.questions import guess_country
|
||||
from pretix.base.models import Event, Order, OrderPayment, OrderRefund, Quota
|
||||
from pretix.base.payment import BasePaymentProvider, PaymentException
|
||||
from pretix.base.settings import SettingsSandbox
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.urls import mainreverse_absolute
|
||||
from pretix.multidomain.urlreverse import eventreverse, eventreverse_absolute
|
||||
from pretix.plugins.paypal2.client.core.environment import (
|
||||
@@ -675,7 +675,7 @@ class PaypalMethod(BasePaymentProvider):
|
||||
return False
|
||||
|
||||
def _execute_payment(self, request: HttpRequest, payment: OrderPayment):
|
||||
payment = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=payment.pk)
|
||||
payment = OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=payment.pk)
|
||||
if payment.state == OrderPayment.PAYMENT_STATE_CONFIRMED:
|
||||
# payment is already confirmed; possible return-view/webhook race-condition
|
||||
return
|
||||
@@ -1002,7 +1002,7 @@ class PaypalMethod(BasePaymentProvider):
|
||||
self.init_api()
|
||||
with transaction.atomic():
|
||||
# Lock payment that we are creating refund for to prevent race condition with incoming webhook
|
||||
OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=refund.payment_id)
|
||||
OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=refund.payment_id)
|
||||
try:
|
||||
pp_payment = None
|
||||
payment_info_data = None
|
||||
|
||||
@@ -61,7 +61,7 @@ from pretix.base.payment import PaymentException
|
||||
from pretix.base.services.cart import add_payment_to_cart, get_fees
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
from pretix.control.permissions import event_permission_required
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.http import redirect_to_url
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.plugins.paypal2.client.customer.partners_merchantintegrations_get_request import (
|
||||
@@ -460,7 +460,7 @@ def webhook(request, *args, **kwargs):
|
||||
|
||||
with transaction.atomic():
|
||||
# Lock payment in case a refund is currently still running
|
||||
payment = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=payment.pk)
|
||||
payment = OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=payment.pk)
|
||||
known_refunds = {r.info_data.get('id'): r for r in payment.refunds.all()}
|
||||
if refund['id'] not in known_refunds:
|
||||
payment.create_external_refund(
|
||||
|
||||
@@ -55,7 +55,7 @@ from pretix.base.signals import (
|
||||
EventPluginSignal, event_copy_data, periodic_task,
|
||||
)
|
||||
from pretix.control.signals import nav_event
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.plugins.sendmail.models import Rule, ScheduledMail
|
||||
from pretix.plugins.sendmail.views import OrderSendView, WaitinglistSendView
|
||||
|
||||
@@ -206,7 +206,7 @@ def sendmail_run_rules(sender, **kwargs):
|
||||
|
||||
with transaction.atomic(durable=True):
|
||||
m = ScheduledMail.objects.select_for_update(
|
||||
of=OF_SELF,
|
||||
**LOCK_SELF_NO_KEY,
|
||||
skip_locked=connection.features.has_select_for_update_skip_locked
|
||||
).filter(pk=m_id).first()
|
||||
if not m or m.state not in (ScheduledMail.STATE_SCHEDULED, ScheduledMail.STATE_FAILED):
|
||||
|
||||
@@ -72,7 +72,7 @@ from pretix.base.payment import (
|
||||
from pretix.base.plugins import get_all_plugins
|
||||
from pretix.base.settings import SettingsSandbox
|
||||
from pretix.base.views.redirect import safelink
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.countries import CachedCountries
|
||||
from pretix.helpers.http import get_client_ip
|
||||
from pretix.helpers.urls import mainreverse_absolute
|
||||
@@ -753,7 +753,7 @@ class StripeMethod(BasePaymentProvider):
|
||||
self._init_api()
|
||||
|
||||
payment_info = refund.payment.info_data
|
||||
OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=refund.payment.pk)
|
||||
OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=refund.payment.pk)
|
||||
|
||||
if not payment_info:
|
||||
raise PaymentException(_('No payment information found.'))
|
||||
|
||||
@@ -60,7 +60,7 @@ from pretix.control.permissions import (
|
||||
)
|
||||
from pretix.control.views.event import DecoupleMixin
|
||||
from pretix.control.views.organizer import OrganizerDetailViewMixin
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.http import redirect_to_url
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.plugins.stripe.forms import OrganizerStripeSettingsForm
|
||||
@@ -279,13 +279,13 @@ def charge_webhook(event, event_json, charge_id, rso):
|
||||
|
||||
with transaction.atomic():
|
||||
if payment:
|
||||
payment = OrderPayment.objects.select_for_update(of=OF_SELF).get(pk=payment.pk)
|
||||
payment = OrderPayment.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=payment.pk)
|
||||
else:
|
||||
payment = order.payments.filter(
|
||||
info__icontains=charge['id'],
|
||||
provider__startswith='stripe',
|
||||
amount=prov._amount_to_decimal(charge['amount']),
|
||||
).select_for_update(of=OF_SELF).last()
|
||||
).select_for_update(**LOCK_SELF_NO_KEY).last()
|
||||
if not payment:
|
||||
payment = order.payments.create(
|
||||
state=OrderPayment.PAYMENT_STATE_CREATED,
|
||||
|
||||
@@ -54,7 +54,7 @@ from pretix.base.models import Customer, InvoiceAddress, Order, OrderPosition
|
||||
from pretix.base.services.mail import mail
|
||||
from pretix.base.settings import PERSON_NAME_SCHEMES
|
||||
from pretix.base.signals import customer_created, customer_signed_in
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers import LOCK_SELF_NO_KEY
|
||||
from pretix.helpers.compat import CompatDeleteView
|
||||
from pretix.helpers.http import redirect_to_url
|
||||
from pretix.multidomain.models import KnownDomain
|
||||
@@ -280,7 +280,7 @@ class SetPasswordView(FormView):
|
||||
def form_valid(self, form):
|
||||
with transaction.atomic():
|
||||
# Re-check token in transaction to prevent race condition
|
||||
self.customer = Customer.objects.select_for_update(of=OF_SELF).get(pk=self.customer.pk)
|
||||
self.customer = Customer.objects.select_for_update(**LOCK_SELF_NO_KEY).get(pk=self.customer.pk)
|
||||
if not TokenGenerator().check_token(self.customer, self.request.GET.get('token', '')):
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
|
||||
Reference in new issue
Block a user