gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: instantiate and show th


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: instantiate and show the wire transfer form
Date: Thu, 16 Nov 2017 13:12:07 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new 75fbd51  instantiate and show the wire transfer form
75fbd51 is described below

commit 75fbd510eb785c425dadff42a4481209e179167a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Nov 16 13:11:39 2017 +0100

    instantiate and show the wire transfer form
---
 talerbank/app/templates/profile_page.html | 24 ++++++++++++++++++++++++
 talerbank/app/views.py                    | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/talerbank/app/templates/profile_page.html 
b/talerbank/app/templates/profile_page.html
index 1e4633a..74dfb85 100644
--- a/talerbank/app/templates/profile_page.html
+++ b/talerbank/app/templates/profile_page.html
@@ -44,6 +44,17 @@
   <section id="main">
     <article>
       <div class="notification">
+        {% if wire_transfer_error %}
+        <p class="informational informational-fail">
+        Could not perform wire transfer, check all fields are correctly
+        entered.
+        </p>
+        {% endif %}
+        {% if just_wire_transferred %}
+        <p class="informational informational-ok">
+        Wire transfer done!
+        </p>
+        {% endif %}
         {% if no_initial_bonus %}
         <p class="informational informational-fail">
           No initial bonus given, poor bank!
@@ -103,6 +114,19 @@
                  disabled
                  value="Select exchange provider"></input>
         </form>
+        <h2>Wire transfer</h2>
+        <form id="wt-form"
+              class="pure-form"
+              action="{{ url('profile') }}"
+              method="post"
+              name="tform">
+
+          <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token 
}}">
+          {{ wt_form }}
+          <input class="pure-button pure-button-primary"
+                 type="submit"
+                 value="Submit"></input>
+        </form>
       </div>
       <p>
       </p>
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 8900c87..6732b00 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -89,11 +89,34 @@ def get_session_flag(request, name):
     return False
 
 
+class WTForm(forms.Form):
+    '''Form used to wire transfer funds internally in the bank.'''
+    amount = forms.DecimalField(label=settings.TALER_CURRENCY)
+    counterpart = forms.IntegerField()
+    subject = forms.CharField()
+
 # Check if user's logged in.  Check if he/she has withdrawn or
 # registered; render profile page.
 
 @login_required
 def profile_page(request):
+    if request.method == "POST":
+        wtf = WTForm(request.POST)
+        if wtf.is_valid(): 
+            try:
+                wire_transfer(Amount.parse(settings.TALER_CURRENCY + ":" + 
str(wtf.cleaned_data.get("amount"))),
+                              BankAccount.objects.get(user=request.user),
+                              
BankAccount.objects.get(account_no=wtf.cleaned_data.get("counterpart")),
+                              wtf.cleaned_data.get("subject"))
+                session["just_wire_transferred"] = True
+            except WireTransferException:
+                session["wire_transfer_error"] = True
+
+    else:
+        wtf = WTForm()
+
+    just_wire_transferred = get_session_flag(request, "just_wire_transferred")
+    wire_transfer_error = get_session_flag(request, "wire_transfer_error")
     just_withdrawn = get_session_flag(request, "just_withdrawn")
     just_registered = get_session_flag(request, "just_registered")
     no_initial_bonus = get_session_flag(request, "no_initial_bonus")
@@ -108,6 +131,7 @@ def profile_page(request):
         precision=settings.TALER_DIGITS,
         currency=user_account.amount.currency,
         account_no=user_account.account_no,
+        wt_form = wtf,
         history=history,
         just_withdrawn=just_withdrawn,
         just_registered=just_registered,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]