Upgrade to Celery 4

This commit is contained in:
Raphael Michel
2016-12-08 13:20:27 +01:00
parent 89732a3057
commit b6e42d64da
9 changed files with 24 additions and 68 deletions

View File

@@ -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: