lingo: move utils functions to file (#46503)
This commit is contained in:
parent
1dfb67c452
commit
c5662aa6b6
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# lingo - basket and payment system
|
||||
# Copyright (C) 2020 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.core import signing
|
||||
|
||||
|
||||
def signing_dumps(content):
|
||||
serialization = signing.dumps(content)
|
||||
return serialization.replace(':', '.')
|
||||
|
||||
|
||||
def signing_loads(serialization):
|
||||
serialization = serialization.replace('.', ':')
|
||||
return signing.loads(serialization)
|
|
@ -48,6 +48,7 @@ from combo.public.views import publish_page
|
|||
|
||||
from .models import (Regie, BasketItem, Transaction, TransactionOperation,
|
||||
LingoBasketCell, SelfDeclaredInvoicePayment, PaymentBackend, EXPIRED)
|
||||
from .utils import signing_dumps, signing_loads
|
||||
|
||||
|
||||
class ErrorJsonResponse(JsonResponse):
|
||||
|
@ -60,16 +61,6 @@ class BadRequestJsonResponse(ErrorJsonResponse):
|
|||
status_code = 400
|
||||
|
||||
|
||||
def signing_dumps(content):
|
||||
serialization = signing.dumps(content)
|
||||
return serialization.replace(':', '.')
|
||||
|
||||
|
||||
def signing_loads(serialization):
|
||||
serialization = serialization.replace('.', ':')
|
||||
return signing.loads(serialization)
|
||||
|
||||
|
||||
def get_eopayment_object(request, regie_or_payment_backend, transaction_id=None):
|
||||
payment_backend = regie_or_payment_backend
|
||||
if isinstance(regie_or_payment_backend, Regie):
|
||||
|
|
Loading…
Reference in New Issue