From ceaefbd0da8158d5e05a4e9738ee047f97217f76 Mon Sep 17 00:00:00 2001
From: Florian Dold
Date: Thu, 30 Nov 2017 17:49:30 +0100
Subject: 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)
-@app.route("/pick", methods=["POST"])
+
+@app.route("/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())
-@app.route("/", 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"),
+
+@app.route("/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
+
+
+@app.route("/", 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 @@
-