summaryrefslogtreecommitdiff
path: root/talerbank
diff options
context:
space:
mode:
authorms <ms@taler.net>2021-06-02 17:31:48 +0200
committerms <ms@taler.net>2021-06-02 17:31:48 +0200
commitdf1a91c06fffe37f9ba99963829b35cfdb874450 (patch)
tree4d549c5ef64d6b60b8e156f7c7fbd1c44fdfa190 /talerbank
parent52a82707453275829ab8085ad1b04dc0341acc01 (diff)
downloadbank-df1a91c06fffe37f9ba99963829b35cfdb874450.tar.gz
bank-df1a91c06fffe37f9ba99963829b35cfdb874450.tar.bz2
bank-df1a91c06fffe37f9ba99963829b35cfdb874450.zip
implement wire-transfer form
Diffstat (limited to 'talerbank')
-rw-r--r--talerbank/app/templates/payto_wiretransfer.html1
-rw-r--r--talerbank/app/templates/profile_page.html2
-rw-r--r--talerbank/app/templates/wiretransfer.html71
-rw-r--r--talerbank/app/urls.py1
-rw-r--r--talerbank/app/views.py44
5 files changed, 117 insertions, 2 deletions
diff --git a/talerbank/app/templates/payto_wiretransfer.html b/talerbank/app/templates/payto_wiretransfer.html
index b435248..06a2fd5 100644
--- a/talerbank/app/templates/payto_wiretransfer.html
+++ b/talerbank/app/templates/payto_wiretransfer.html
@@ -59,7 +59,6 @@
type="submit"
value={{ _("Confirm") }} />
</form>
- <p><a href=" {{ url('profile') }}">Cancel</a></p>
</div>
</article>
</section>
diff --git a/talerbank/app/templates/profile_page.html b/talerbank/app/templates/profile_page.html
index b62e4fb..0abecc4 100644
--- a/talerbank/app/templates/profile_page.html
+++ b/talerbank/app/templates/profile_page.html
@@ -75,7 +75,7 @@
</article>
<article>
<h2>{{ _("Transactions for") }} {{ name }}</h2>
- <p><a href={{ url('payto-form') }}>{{_("Transfer money manually") }}</a></p>
+ <p><a href={{ url('wiretransfer-form') }}>{{_("Transfer money manually") }}</a></p>
<div id="transactions-history">
{% if history %}
<table class="pure-table">
diff --git a/talerbank/app/templates/wiretransfer.html b/talerbank/app/templates/wiretransfer.html
new file mode 100644
index 0000000..0813d97
--- /dev/null
+++ b/talerbank/app/templates/wiretransfer.html
@@ -0,0 +1,71 @@
+{% extends "base.html" %}
+{#
+ This file is part of GNU TALER.
+ Copyright (C) 2014, 2015, 2016 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+
+ @author Marcello Stanisci
+ @author Florian Dold <dold@taler.net>
+#}
+
+{% block main %}
+
+<div>
+ <a href="{{ url('logout') }}" class="pure-button">[{{ _("Logout") }}]</a><br>
+</div>
+
+ <section id="main">
+
+ {% if hint != "" %}
+ <article>
+ <div class="notification">
+ {% if not is_success %}
+ <p class="informational informational-fail">
+ {% else %}
+ <p class="informational informational-ok">
+ {% endif %}
+ {{ hint }}
+ </p>
+ </div>
+ </article>
+ {% endif %}
+
+ <article>
+ <div>
+ <h2>{{ _("Wire transfer") }}</h2>
+ <p>{{ _("Transfer money to another account of this bank:") }}
+ <br>
+ <br>
+ </p>
+ <form action="{{ url('wiretransfer-form') }}"
+ method="POST"
+ name="wire-transfer-form">
+ <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}" />
+ <input name="receiver" placeholder={{ _("receiver") }} />
+ <br>
+ <br>
+ <input name="subject" placeholder={{ _("subject") }} />
+ <br>
+ <br>
+ <input name="amount"
+ placeholder={{ _("amount (CURRENCY:X.YY)") }}
+ pattern="{{ currency }}:[0-9]+(\.[0-9]+)?"/>
+ <br>
+ <br>
+ <input class="pure-button pure-button-primary" type="submit" value={{ _("Confirm") }} />
+ </form>
+ <p><a href="{{ url('payto-form') }}">Want to try the raw payto://-format?</a></p>
+ </div>
+ </article>
+ </section>
+{% endblock %}
diff --git a/talerbank/app/urls.py b/talerbank/app/urls.py
index a27c6d5..9a41a13 100644
--- a/talerbank/app/urls.py
+++ b/talerbank/app/urls.py
@@ -117,6 +117,7 @@ urlpatterns += i18n_patterns(
path("register", views.register, name="register"),
path("profile", views.profile_page, name="profile"),
path("payto-form", views.payto_form, name="payto-form"),
+ path("wiretransfer-form", views.wiretransfer_form, name="wiretransfer-form"),
path(
"login",
auth_views.LoginView.as_view(
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index c0f0303..6a9b3a2 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -295,6 +295,50 @@ class PaytoTransferForm(forms.Form):
@login_required
+def wiretransfer_form(request):
+ if request.method == "GET":
+ is_success, hint = get_session_hint(request)
+ context = dict(
+ currency=request.user.bankaccount.balance.amount.currency,
+ is_success=is_success,
+ hint=hint,
+ )
+ return render(request, "wiretransfer.html", context)
+
+ # A payment was submitted.
+ try:
+ amount = Amount.parse(request.POST.get("amount"))
+ except Exception:
+ set_session_hint(request, success=False, hint="Wrong amount specified.")
+ return redirect("wiretransfer-form")
+ try:
+ receiver_user = User.objects.get(username=request.POST.get("receiver"))
+ except User.DoesNotExist:
+ set_session_hint(request, success=False, hint="Money receiver was not found")
+ return redirect("wiretransfer-form")
+
+ try:
+
+ wire_transfer(
+ amount,
+ request.user.bankaccount,
+ receiver_user.bankaccount,
+ request.POST.get("subject", "not given")
+ )
+ except Exception as exception:
+ hint = str(exception)
+ if hasattr(exception, "hint"):
+ hint = exception.hint
+ set_session_hint(request, success=False, hint=hint)
+ return redirect("wiretransfer-form")
+
+ set_session_hint(request, success=True, hint=gettext("Wire transfer successful!"))
+ return redirect("profile")
+
+
+
+
+@login_required
def payto_form(request):
is_success, hint = get_session_hint(request)
context = dict(