[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-bank] branch master updated: add transfer option with payto
From: |
gnunet |
Subject: |
[taler-bank] branch master updated: add transfer option with payto |
Date: |
Fri, 09 Oct 2020 17:35:28 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new 026e6e3 add transfer option with payto
026e6e3 is described below
commit 026e6e3ec43497c8dbc37a92552f2bb740550678
Author: MS <ms@taler.net>
AuthorDate: Fri Oct 9 17:35:07 2020 +0200
add transfer option with payto
---
talerbank/app/templates/profile_page.html | 40 +++++++++++-------
talerbank/app/urls.py | 33 ++++++++-------
talerbank/app/views.py | 70 +++++++++++++++----------------
3 files changed, 74 insertions(+), 69 deletions(-)
diff --git a/talerbank/app/templates/profile_page.html
b/talerbank/app/templates/profile_page.html
index d35f245..db22b73 100644
--- a/talerbank/app/templates/profile_page.html
+++ b/talerbank/app/templates/profile_page.html
@@ -45,7 +45,6 @@
<article>
<div>
<h2>Withdraw Money into a Taler wallet</h2>
-
<form id="reserve-form"
class="pure-form"
action="{{ url('start-withdrawal') }}"
@@ -64,29 +63,38 @@
</select>
{%- endif -%}
<input type="text" readonly class="currency-indicator" size="{{
currency|length }}" tabindex="-1" value="{{ currency }}">
-
<input id="select-exchange"
class="pure-button pure-button-primary"
type="submit"
value="Start withdrawal" />
+ </form>
</div>
- <p>
- </p>
</article>
<article>
+ <div>
<h2>Wire transfer</h2>
- <div>
- <form action="{{ url('payto-transfer') }}">
- <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token
}}" />
- <input name="payto-transfer-address"
- placeholder="payto address"
- pattern="payto://x-taler-bank/[a-z\.]+(:[0-9]+)?/[a-z0-9]+" />
- <input name="payto-transfer-amount"
- placeholder="amount"
- pattern="[0-9]+(\.[0-9][0-9])?" />
- <input type="text" readonly class="currency-indicator" size="{{
currency|length }}" tabindex="-1" value="{{ currency }}">
- </form>
- </div>
+ <form action="{{ url('payto-transfer') }}"
+ method="POST"
+ name="payto-form">
+ <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token
}}" />
+ <input name="address"
+ placeholder="payto address"
+ pattern="payto://x-taler-bank/[a-z\.]+(:[0-9]+)?/[0-9]+" />
+ <input name="amount"
+ placeholder="amount"
+ pattern="[0-9]+(\.[0-9][0-9])?" />
+ <input name="subject"
+ placeholder="subject" />
+ <input type="text"
+ readonly
+ class="currency-indicator"
+ size="{{ currency|length }}"
+ tabindex="-1"value="{{ currency }}">
+ <input class="pure-button pure-button-primary"
+ type="submit"
+ value="Confirm" />
+ </form>
+ </div>
</article>
<article>
<h2>Transactions for {{ name }}</h2>
diff --git a/talerbank/app/urls.py b/talerbank/app/urls.py
index 0c624f1..71d87bf 100644
--- a/talerbank/app/urls.py
+++ b/talerbank/app/urls.py
@@ -110,28 +110,29 @@ urlpatterns = [
),
path("", RedirectView.as_view(pattern_name="profile"), name="index"),
path("favicon.ico", views.ignore),
- path(
- "login",
- auth_views.LoginView.as_view(
- template_name="login.html",
- authentication_form=views.TalerAuthenticationForm,
- ),
- name="login",
+ path("login",
+ auth_views.LoginView.as_view(
+ template_name="login.html",
+ authentication_form=views.TalerAuthenticationForm,
+ ),
+ name="login"
),
path("config", views.config_view, name="config"),
path("logout", views.logout_view, name="logout"),
path("register", views.register, name="register"),
path("profile", views.profile_page, name="profile"),
path("history", views.serve_history, name="history"),
- path("public-accounts", views.serve_public_accounts,
name="public-accounts"),
- path(
- "public-accounts/<str:name>",
- views.serve_public_accounts,
- name="public-accounts",
+ path("public-accounts",
+ views.serve_public_accounts, name="public-accounts"),
+ path("public-accounts/<str:name>",
+ views.serve_public_accounts,
+ name="public-accounts"
),
- path(
- "public-accounts/<str:name>/<int:page>",
- views.serve_public_accounts,
- name="public-accounts",
+ path("public-accounts/<str:name>/<int:page>",
+ views.serve_public_accounts,
+ name="public-accounts"
),
+ path("payto-transfer",
+ views.payto_transfer,
+ name="payto-transfer")
]
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 044f784..f6d81ce 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -293,22 +293,11 @@ class InputDatalist(forms.TextInput):
datalist += "</datalist>"
return html + datalist
-
-class WTForm(forms.Form):
- """
- Form for sending wire transfers. It usually appears in the
- user profile page.
- """
-
- amount = forms.FloatField(
- min_value=0.1, widget=forms.NumberInput(attrs={"class":
"currency-input"})
- )
- receiver = forms.IntegerField(
- min_value=1, widget=InputDatalist(predefined_accounts_list, "receiver")
- )
+class PaytoTransferForm(forms.Form):
+ amount = forms.FloatField(min_value=0.1, widget=forms.NumberInput())
+ address = forms.CharField()
subject = forms.CharField()
-
##
# This method serves the profile page, which is the main
# page where the user interacts with the bank, and also the
@@ -325,28 +314,6 @@ class WTForm(forms.Form):
# @return Django-specific HTTP response object.
@login_required
def profile_page(request):
- if request.method == "POST":
- # WTForm ~ Wire Transfer Form.
- wtf = WTForm(request.POST)
- if wtf.is_valid():
- amount_parts = (
- settings.TALER_CURRENCY,
- wtf.cleaned_data.get("amount") + 0.0,
- )
- wire_transfer(
- Amount.parse("%s:%s" % amount_parts),
- BankAccount.objects.get(user=request.user),
-
BankAccount.objects.get(account_no=wtf.cleaned_data.get("receiver")),
- wtf.cleaned_data.get("subject"),
- )
-
- set_session_hint(
- request, success=True, hint="Wire transfer successful!"
- )
-
- return redirect("profile")
-
- wtf = WTForm()
is_success, hint = get_session_hint(request)
context = dict(
name=request.user.username,
@@ -356,7 +323,6 @@ def profile_page(request):
precision=settings.TALER_DIGITS,
currency=request.user.bankaccount.balance.amount.currency,
account_no=request.user.bankaccount.account_no,
- wt_form=wtf,
history=extract_history(request.user.bankaccount, -1 * (UINT64_MAX / 2
/ 2)),
)
if settings.TALER_SUGGESTED_EXCHANGE:
@@ -369,6 +335,36 @@ def profile_page(request):
response.status_code = 202
return response
+@login_required
+@require_POST
+def payto_transfer(request):
+ data = PaytoTransferForm(request.POST)
+ if not data.is_valid():
+ set_session_hint(
+ request,
+ success=False,
+ hint="Bad form submitted!"
+ )
+ return redirect("profile")
+
+ amount_parts = (
+ settings.TALER_CURRENCY,
+ data.cleaned_data.get("amount") + 0.0
+ )
+ parsed_address = PaytoParse(data.cleaned_data.get("address"))
+
+ wire_transfer(
+ Amount.parse("%s:%s" % amount_parts),
+ BankAccount.objects.get(user=request.user),
+ BankAccount.objects.get(account_no=parsed_address.account),
+ data.cleaned_data.get("subject")
+ )
+ set_session_hint(
+ request,
+ success=True,
+ hint="Wire transfer successful!"
+ )
+ return redirect("profile")
##
# Helper function that hashes its input. Usually
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-bank] branch master updated: add transfer option with payto,
gnunet <=