summaryrefslogtreecommitdiff
path: root/talersurvey/survey
diff options
context:
space:
mode:
Diffstat (limited to 'talersurvey/survey')
-rw-r--r--talersurvey/survey/survey.py24
-rw-r--r--talersurvey/survey/templates/index.html6
2 files changed, 15 insertions, 15 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 @@
</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>