gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-survey] branch master updated: separate submit URL


From: gnunet
Subject: [GNUnet-SVN] [taler-survey] branch master updated: separate submit URL
Date: Thu, 30 Nov 2017 17:49:41 +0100

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

dold pushed a commit to branch master
in repository survey.

The following commit(s) were added to refs/heads/master by this push:
     new ceaefbd  separate submit URL
ceaefbd is described below

commit ceaefbd0da8158d5e05a4e9738ee047f97217f76
Author: Florian Dold <address@hidden>
AuthorDate: Thu Nov 30 17:49:30 2017 +0100

    separate submit URL
---
 talersurvey/survey/survey.py            | 24 ++++++++++++++----------
 talersurvey/survey/templates/index.html |  6 +-----
 talersurvey/tests.py                    |  6 +++---
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index f4e7824..d44db73 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -46,6 +46,7 @@ def backend_error(requests_response):
                      + str(requests_response.status_code))
         return flask.jsonify(dict(error="Backend died, no JSON got from it")), 
502
 
+
 @app.context_processor
 def utility_processor():
     def join_urlparts(*parts):
@@ -67,21 +68,19 @@ def utility_processor():
         return os.environ.get(name, default)
     return dict(url=url, env=env)
 
address@hidden("/pick", methods=["POST"])
+
address@hidden("/tip-pickup", methods=["POST"])
 def pick():
     body = flask.request.get_json()
-    r = requests.post(urljoin(BACKEND_URL, 'tip-pickup'),
-                      json=body)
+    r = requests.post(urljoin(BACKEND_URL, 'tip-pickup'), json=body)
     if 200 != r.status_code:
         return backend_error(r)
-    else:
-        return flask.jsonify(r.json())
+    return flask.jsonify(r.json())
 
address@hidden("/", methods=["GET", "POST"])
-def survey():
-    if flask.request.method == "GET":
-        return flask.render_template("templates/index.html", 
merchant_currency=CURRENCY)
-    tip_spec = dict(pickup_url=urljoin(flask.request.base_url, "/pick"),
+
address@hidden("/submit-survey", methods=["POST"])
+def submit_survey():
+    tip_spec = dict(pickup_url=urljoin(flask.request.base_url, "/tip-pickup"),
                     amount=Amount(CURRENCY, 1).dump(),
                     instance="default",
                     justification="Payment methods survey")
@@ -95,3 +94,8 @@ def survey():
     response.headers["X-Taler-Tip"] = r.json()["tip_token"]
 
     return response
+
+
address@hidden("/", methods=["GET"])
+def survey():
+    return flask.render_template("templates/index.html", 
merchant_currency=CURRENCY)
diff --git a/talersurvey/survey/templates/index.html 
b/talersurvey/survey/templates/index.html
index d3b873d..edcdb85 100644
--- a/talersurvey/survey/templates/index.html
+++ b/talersurvey/survey/templates/index.html
@@ -8,11 +8,7 @@
     </p>
   </div>
   <div>
-    <form action="{{ url('/') }}" method="post">
-      {% if success %}
-        <strong>Congratulations, your reward has been successfully 
submitted!</strong>
-        <br>
-      {% endif %}
+    <form action="{{ url('/submit-survey') }}" method="post">
       What do you prefer?<br>
       <input type="radio" name="paypref" value="taler" checked="checked">
         <label>Taler</label>
diff --git a/talersurvey/tests.py b/talersurvey/tests.py
index c2104bd..56e66e4 100644
--- a/talersurvey/tests.py
+++ b/talersurvey/tests.py
@@ -23,11 +23,11 @@ class SurveyTestCase(unittest.TestCase):
             "exchange_uri": "http://exchange.example.com/";,
             "expiration": "/Date(2018)/"}
         mocked_post.return_value = ret_post
-        self.app.post("/")
+        self.app.post("/submit-survey")
         mocked_post.assert_called_with(
             "http://backend.test.taler.net/tip-authorize";,
             json={
-               "pickup_url": "http://localhost/pick";,
+               "pickup_url": "http://localhost/tip-pickup";,
                 "amount": {
                     "value": 1,
                     "fraction": 0,
@@ -41,7 +41,7 @@ class SurveyTestCase(unittest.TestCase):
         ret_post.status_code = 200
         ret_post.json.return_value = {}
         mocked_post.return_value = ret_post
-        self.app.post("/pick",
+        self.app.post("/tip-pickup",
                       data="{}",
                       content_type="application/json")
         mocked_post.assert_called_with(

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



reply via email to

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