mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Upgrade to Celery 4
This commit is contained in:
@@ -11,8 +11,7 @@ from django.views.generic.base import TemplateResponseMixin
|
||||
|
||||
from pretix.base.models import Order
|
||||
from pretix.base.models.orders import InvoiceAddress
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.services.orders import OrderError, perform_order
|
||||
from pretix.base.services.orders import perform_order
|
||||
from pretix.base.signals import register_payment_providers
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.presale.forms.checkout import ContactForm, InvoiceAddressForm
|
||||
@@ -294,6 +293,7 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
identifier = "confirm"
|
||||
template_name = "pretixpresale/event/checkout_confirm.html"
|
||||
task = perform_order
|
||||
known_errortypes = ['OrderError']
|
||||
|
||||
def is_applicable(self, request):
|
||||
return True
|
||||
@@ -350,11 +350,7 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
return self.get_order_url(order)
|
||||
|
||||
def get_error_message(self, exception):
|
||||
if isinstance(exception, dict) and exception['exc_type'] == 'OrderError':
|
||||
return exception['exc_message']
|
||||
elif isinstance(exception, OrderError):
|
||||
return str(exception)
|
||||
elif isinstance(exception, SendMailException):
|
||||
if exception.__class__.__name__ == 'SendMailException':
|
||||
return _('There was an error sending the confirmation mail. Please try again later.')
|
||||
return super().get_error_message(exception)
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ class CartActionMixin:
|
||||
|
||||
class CartRemove(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||
task = remove_items_from_cart
|
||||
known_errortypes = ['CartError']
|
||||
|
||||
def get_success_message(self, value):
|
||||
if CartPosition.objects.filter(cart_id=self.request.session.session_key).exists():
|
||||
@@ -109,13 +110,6 @@ class CartRemove(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||
else:
|
||||
return _('Your cart is empty.')
|
||||
|
||||
def get_error_message(self, exception):
|
||||
if isinstance(exception, dict) and exception['exc_type'] == 'CartError':
|
||||
return exception['exc_message']
|
||||
elif isinstance(exception, CartError):
|
||||
return str(exception)
|
||||
return super().get_error_message(exception)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
items = self._items_from_post_data()
|
||||
if items:
|
||||
@@ -131,17 +125,11 @@ class CartRemove(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||
|
||||
class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||
task = add_items_to_cart
|
||||
known_errortypes = ['CartError']
|
||||
|
||||
def get_success_message(self, value):
|
||||
return _('The products have been successfully added to your cart.')
|
||||
|
||||
def get_error_message(self, exception):
|
||||
if isinstance(exception, dict) and exception['exc_type'] == 'CartError':
|
||||
return exception['exc_message']
|
||||
elif isinstance(exception, CartError):
|
||||
return str(exception)
|
||||
return super().get_error_message(exception)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
items = self._items_from_post_data()
|
||||
if items:
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.http import FileResponse, Http404, HttpResponse
|
||||
from django.shortcuts import redirect, render
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext, ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import TemplateView, View
|
||||
|
||||
from pretix.base.models import CachedTicket, Invoice, Order, OrderPosition
|
||||
@@ -13,7 +13,7 @@ from pretix.base.models.orders import InvoiceAddress
|
||||
from pretix.base.services.invoices import (
|
||||
generate_cancellation, generate_invoice, invoice_pdf, invoice_qualified,
|
||||
)
|
||||
from pretix.base.services.orders import OrderError, cancel_order
|
||||
from pretix.base.services.orders import cancel_order
|
||||
from pretix.base.services.tickets import generate
|
||||
from pretix.base.signals import (
|
||||
register_payment_providers, register_ticket_outputs,
|
||||
@@ -462,6 +462,7 @@ class OrderCancel(EventViewMixin, OrderDetailMixin, TemplateView):
|
||||
|
||||
class OrderCancelDo(EventViewMixin, OrderDetailMixin, AsyncAction, View):
|
||||
task = cancel_order
|
||||
known_errortypes = ['OrderError']
|
||||
|
||||
def get_success_url(self, value):
|
||||
return self.get_order_url()
|
||||
@@ -485,13 +486,6 @@ class OrderCancelDo(EventViewMixin, OrderDetailMixin, AsyncAction, View):
|
||||
def get_success_message(self, value):
|
||||
return _('The order has been canceled.')
|
||||
|
||||
def get_error_message(self, exception):
|
||||
if isinstance(exception, dict) and exception['exc_type'] == 'OrderError':
|
||||
return gettext(exception['exc_message'])
|
||||
elif isinstance(exception, OrderError):
|
||||
return str(exception)
|
||||
return super().get_error_message(exception)
|
||||
|
||||
|
||||
class OrderDownload(EventViewMixin, OrderDetailMixin, View):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user