[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-survey] branch master updated: add survey stats
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-survey] branch master updated: add survey stats |
Date: |
Thu, 01 Feb 2018 07:34:27 +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 18ae5c3 add survey stats
18ae5c3 is described below
commit 18ae5c327d1a1e069e4350c27b3f09b82c130a57
Author: Florian Dold <address@hidden>
AuthorDate: Thu Feb 1 07:34:20 2018 +0100
add survey stats
---
talersurvey/survey/survey.py | 21 +++++++++++++++++++++
talersurvey/survey/templates/base.html | 9 +--------
talersurvey/survey/templates/index.html | 2 +-
talersurvey/survey/templates/survey_stats.html | 15 +++++++++++++++
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())
address@hidden("/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 %}
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-survey] branch master updated: add survey stats,
gnunet <=