summaryrefslogtreecommitdiff
path: root/talerbank/app/views.py
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-29 19:25:58 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-29 19:25:58 +0100
commit589c8383153b57860c76336a4c35ed9975e8e9e5 (patch)
tree7b954805175baf2e3cdf803055a83843e4ee4ad3 /talerbank/app/views.py
parent95cd26305979cb765751fd7bdfe6c61f3972fc0e (diff)
downloadbank-589c8383153b57860c76336a4c35ed9975e8e9e5.tar.gz
bank-589c8383153b57860c76336a4c35ed9975e8e9e5.tar.bz2
bank-589c8383153b57860c76336a4c35ed9975e8e9e5.zip
move PaytoParse logic into taler-util (#6650)
Diffstat (limited to 'talerbank/app/views.py')
-rw-r--r--talerbank/app/views.py22
1 files changed, 1 insertions, 21 deletions
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 7177d7f..0c92362 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -49,6 +49,7 @@ from django.core.exceptions import ObjectDoesNotExist
from datetime import datetime
from .models import BankAccount, BankTransaction, TalerWithdrawOperation
from taler.util.amount import Amount, SignedAmount
+from taler.util.payto import PaytoParse
from taler.util.taler_error_codes import ErrorCode
from http import HTTPStatus
@@ -99,27 +100,6 @@ def allow_origin_star(view_func):
return wraps(view_func)(_decorator)
-class PaytoFormatError(Exception):
- def __init__(self, msg):
- super(PaytoFormatError, self).__init__(msg)
- self.msg = msg
-
-class PaytoParse:
- def __init__(self, payto_uri):
- obj = urlparse(payto_uri)
- path = obj.path.split("/")
- if obj.scheme != "payto" or \
- len(path) != 3 or \
- not obj.netloc or \
- not re.match("^payto://", payto_uri):
- raise PaytoFormatError(f"Bad Payto URI: {payto_uri}")
- self.target = path.pop()
- self.bank = path.pop()
- self.authority = obj.netloc
- params = dict(parse_qsl(obj.query))
- self.message = params.get("message")
- self.amount = Amount.parse(params.get("amount")) if "amount" in params else None
-
##
# Exception raised upon failing login.
#