From 3faa37405b54bec7c873babac69fedbdec44c085 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 30 Sep 2020 18:09:13 +0200 Subject: [PATCH 3/4] lingo: add payment_url property to basket item (#46503) --- combo/apps/lingo/models.py | 7 +++++++ combo/apps/lingo/views.py | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 07def1de..868f260d 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -51,6 +51,8 @@ from combo.data.library import register_cell_class from combo.utils import NothingInCacheException, aes_hex_encrypt, requests from combo.apps.notifications.models import Notification +from .utils import signing_dumps + try: from mellon.models import UserSAMLIdentifier except ImportError: @@ -439,6 +441,11 @@ class BasketItem(models.Model): def total_amount(self): return self.amount + @property + def payment_url(self): + signature = signing_dumps(self.pk) + return reverse('basket-item-pay-view', kwargs={'item_signature': signature }) + class RemoteItem(object): payment_date = None diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py index d1a97463..de483415 100644 --- a/combo/apps/lingo/views.py +++ b/combo/apps/lingo/views.py @@ -221,13 +221,8 @@ class AddBasketItemApiView(View): if item.regie.extra_fees_ws_url: BadRequestJsonResponse('can not compute extra fees with anonymous user') - payment_url = reverse( - 'basket-item-pay-view', - kwargs={ - 'item_signature': signing_dumps(item.pk) - }) return JsonResponse({'result': 'success', 'id': str(item.id), - 'payment_url': request.build_absolute_uri(payment_url)}) + 'payment_url': request.build_absolute_uri(item.payment_url)}) class RemoveBasketItemApiView(View): -- 2.20.1