0002-lingo-move-utils-functions-to-file-46503.patch
combo/apps/lingo/utils.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# lingo - basket and payment system |
|
3 |
# Copyright (C) 2020 Entr'ouvert |
|
4 |
# |
|
5 |
# This program is free software: you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU Affero General Public License as published |
|
7 |
# by the Free Software Foundation, either version 3 of the License, or |
|
8 |
# (at your option) any later version. |
|
9 |
# |
|
10 |
# This program is distributed in the hope that it will be useful, |
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
# GNU Affero General Public License for more details. |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU Affero General Public License |
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 | ||
18 |
from django.core import signing |
|
19 | ||
20 | ||
21 |
def signing_dumps(content): |
|
22 |
serialization = signing.dumps(content) |
|
23 |
return serialization.replace(':', '.') |
|
24 | ||
25 | ||
26 |
def signing_loads(serialization): |
|
27 |
serialization = serialization.replace('.', ':') |
|
28 |
return signing.loads(serialization) |
combo/apps/lingo/views.py | ||
---|---|---|
48 | 48 | |
49 | 49 |
from .models import (Regie, BasketItem, Transaction, TransactionOperation, |
50 | 50 |
LingoBasketCell, SelfDeclaredInvoicePayment, PaymentBackend, EXPIRED) |
51 |
from .utils import signing_dumps, signing_loads |
|
51 | 52 | |
52 | 53 | |
53 | 54 |
class ErrorJsonResponse(JsonResponse): |
... | ... | |
60 | 61 |
status_code = 400 |
61 | 62 | |
62 | 63 | |
63 |
def signing_dumps(content): |
|
64 |
serialization = signing.dumps(content) |
|
65 |
return serialization.replace(':', '.') |
|
66 | ||
67 | ||
68 |
def signing_loads(serialization): |
|
69 |
serialization = serialization.replace('.', ':') |
|
70 |
return signing.loads(serialization) |
|
71 | ||
72 | ||
73 | 64 |
def get_eopayment_object(request, regie_or_payment_backend, transaction_id=None): |
74 | 65 |
payment_backend = regie_or_payment_backend |
75 | 66 |
if isinstance(regie_or_payment_backend, Regie): |
76 |
- |