summaryrefslogtreecommitdiff
path: root/talersurvey
diff options
context:
space:
mode:
Diffstat (limited to 'talersurvey')
-rw-r--r--talersurvey/survey/survey.py21
-rw-r--r--talersurvey/survey/templates/base.html9
-rw-r--r--talersurvey/survey/templates/index.html2
-rw-r--r--talersurvey/survey/templates/survey_stats.html15
4 files changed, 38 insertions, 9 deletions
diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index c5b796c..c5b72b5 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -76,12 +76,33 @@ def backend_post(endpoint, json):
return response_json
+def backend_get(endpoint, params):
+ headers = {"Authorization": "ApiKey " + APIKEY}
+ try:
+ resp = requests.get(urljoin(BACKEND_URL, endpoint), params=params, headers=headers)
+ except requests.ConnectionError:
+ err_abort(500, message="Could not establish connection to backend")
+ try:
+ response_json = resp.json()
+ except ValueError:
+ err_abort(500, message="Could not parse response from backend")
+ if resp.status_code != 200:
+ err_abort(500, message="Backend returned error status",
+ json=response_json, status_code=resp.status_code)
+ return response_json
+
+
@app.errorhandler(Exception)
def internal_error(e):
return flask.render_template("templates/error.html",
message="Internal error",
stack=traceback.format_exc())
+@app.route("/survey-stats", methods=["GET"])
+def survey_stats(e):
+ stats = backend_get("tip-query", instance="default")
+ return flask.render_template("survey_stats.html", stats=stats)
+
@app.route("/submit-survey", methods=["POST"])
def submit_survey():
diff --git a/talersurvey/survey/templates/base.html b/talersurvey/survey/templates/base.html
index 849c53d..bc36c08 100644
--- a/talersurvey/survey/templates/base.html
+++ b/talersurvey/survey/templates/base.html
@@ -40,14 +40,7 @@
</div>
<section id="main" class="content">
- <a href="{{ url_for('index') }}">
- <div id="logo">
- <svg height="100" width="100">
- <circle cx="50" cy="50" r="40" stroke="darkcyan" stroke-width="6" fill="white" />
- <text x="19" y="82" font-family="Verdana" font-size="90" fill="darkcyan">S</text>
- </svg>
- </div>
- </a>
+ <h1>Taler Surve Demo</h1>
{% block main %}
This is the main content of the page.
{% endblock %}
diff --git a/talersurvey/survey/templates/index.html b/talersurvey/survey/templates/index.html
index f40c235..e1ca8ce 100644
--- a/talersurvey/survey/templates/index.html
+++ b/talersurvey/survey/templates/index.html
@@ -4,7 +4,7 @@
<div>
<p>
In this page, you can participate in our survey about payment systems
- and get a nice tip - via your Taler wallet - from this shop!
+ and get a nice tip - via your Taler wallet - from this shop! <a href={{ url_for('survey_stats') }}>(surve stats)</a>
</p>
</div>
<div>
diff --git a/talersurvey/survey/templates/survey_stats.html b/talersurvey/survey/templates/survey_stats.html
new file mode 100644
index 0000000..62c77dd
--- /dev/null
+++ b/talersurvey/survey/templates/survey_stats.html
@@ -0,0 +1,15 @@
+{% extends "templates/base.html" %}
+
+{% block main %}
+ <div>
+ <p>This page shows information about the tipping configuration of the
+ merchant. Usually this should not be visible to users.</p>
+ <ul>
+ <li>Reserve pub: {{ stats['reserve_pub'] }}</li>
+ <li>Reserve expiration: {{ stats['reserve_expiration'] }}</li>
+ <li>Amount available {{ stats['amount_available'] }}</li>
+ <li>Amount picked up {{ stats['amount_picked_up'] }}</li>
+ <li>Amount authorized {{ stats['amount_authorized'] }}</li>
+ <ul>
+ </div>
+{% endblock %}