summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--talersurvey/survey/survey.py24
-rw-r--r--talersurvey/survey/templates/index.html6
-rw-r--r--talersurvey/tests.py6
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 @@
</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(