summaryrefslogtreecommitdiff
path: root/talersurvey
diff options
context:
space:
mode:
Diffstat (limited to 'talersurvey')
-rw-r--r--talersurvey/__init__.py0
-rw-r--r--talersurvey/survey/survey.py54
-rw-r--r--talersurvey/survey/templates/base.html62
-rw-r--r--talersurvey/survey/templates/index.html25
4 files changed, 141 insertions, 0 deletions
diff --git a/talersurvey/__init__.py b/talersurvey/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/talersurvey/__init__.py
diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index e69de29..ab02def 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -0,0 +1,54 @@
+# This file is part of GNU TALER.
+# Copyright (C) 2017 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free Software
+# Foundation; either version 2.1, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License along with
+# GNU TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+#
+# @author Marcello Stanisci
+
+import flask
+import os
+import base64
+from talersurvey.talerconfig import TalerConfig
+
+base_dir = os.path.dirname(os.path.abspath(__file__))
+app = flask.Flask(__name__, template_folder=base_dir)
+app.debug = True
+app.secret_key = base64.b64encode(os.urandom(64)).decode('utf-8')
+tc = TalerConfig.from_env()
+BACKEND_URL = tc["frontends"]["backend"].value_string(required=True)
+CURRENCY = tc["taler"]["currency"].value_string(required=True)
+app.config.from_object(__name__)
+
+@app.context_processor
+def utility_processor():
+ def join_urlparts(*parts):
+ s = ""
+ i = 0
+ while i < len(parts):
+ n = parts[i]
+ i += 1
+ if s.endswith("/"):
+ n = n.lstrip("/")
+ elif s and not n.startswith("/"):
+ n = "/" + n
+ s += n
+ return s
+
+ def url(my_url):
+ return join_urlparts(flask.request.script_root, my_url)
+ def env(name, default=None):
+ return os.environ.get(name, default)
+ return dict(url=url, env=env)
+
+@app.route("/")
+def index():
+ return flask.render_template("templates/index.html", merchant_currency=CURRENCY)
diff --git a/talersurvey/survey/templates/base.html b/talersurvey/survey/templates/base.html
new file mode 100644
index 0000000..dc78eb0
--- /dev/null
+++ b/talersurvey/survey/templates/base.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<!--
+ This file is part of GNU TALER.
+ Copyright (C) 2014, 2015, 2016 INRIA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+-->
+
+<html>
+<head>
+ <title>Taler Donation Demo</title>
+ <link rel="stylesheet" type="text/css" href="{{ url('/static/web-common/pure.css') }}" />
+ <link rel="stylesheet" type="text/css" href="{{ url('/static/web-common/demo.css') }}" />
+ <script src="{{ url("/static/web-common/taler-wallet-lib.js") }}" type="application/javascript"></script>
+ <script src="{{ url("/static/web-common/lang.js") }}" type="application/javascript"></script>
+ {% block styles %}{% endblock %}
+ {% block scripts %}{% endblock %}
+</head>
+
+<body>
+ <div class="demobar">
+ <h1><span class="tt adorn-brackets">Taler Demo</span></h1>
+ <h1><span class="it"><a href="{{ env('TALER_ENV_URL_MERCHANT_DONATIONS') }}">Donations</a></span></h1>
+ <p>This is the donation page, you can make donations (with an imaginary currency for now) to free software projects.</p>
+ <ul>
+ <li><a href="{{ env('TALER_ENV_URL_INTRO', '#') }}">Introduction</a></li>
+ <li><a href="{{ env('TALER_ENV_URL_BANK', '#') }}">Bank</a></li>
+ <li><a href="{{ env('TALER_ENV_URL_MERCHANT_BLOG', '#') }}">Essay Shop</a></li>
+ <li><a href="{{ env('TALER_ENV_URL_MERCHANT_DONATIONS', '#') }}">Donations</a></li>
+ </ul>
+ <p>You can learn more about Taler on our main <a href="https://taler.net">website</a>.</p>
+ </div>
+
+ <section id="main" class="content">
+ <a href="{{ url("/") }}">
+ <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>
+ {% block main %}
+ This is the main content of the page.
+ {% endblock %}
+ <hr />
+ <div class="copyright">
+ <p>Copyright &copy; 2014&mdash;2017 INRIA</p>
+ <a href="/javascript" data-jslicense="1" class="jslicenseinfo">JavaScript license information</a>
+ </div>
+ </section>
+</body>
+</html>
diff --git a/talersurvey/survey/templates/index.html b/talersurvey/survey/templates/index.html
new file mode 100644
index 0000000..f842d6a
--- /dev/null
+++ b/talersurvey/survey/templates/index.html
@@ -0,0 +1,25 @@
+{% extends "templates/base.html" %}
+
+{% block main %}
+ <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!
+ </p>
+ </div>
+ <div>
+ <form action="{{ url('/survey') }}" method="post">
+ {% if success %}
+ <strong>Congratulations, your reward has been successfully submitted!</strong>
+ {% endif %}
+ What do you prefer?<br>
+ <input type="radio" name="paypref" value="taler">
+ <label>Taler</label>
+ </input>
+ <input type="radio" name="paypref" value="visa">
+ <label>Visa</label>
+ </input><br>
+ <input type="submit" value="Submit"></input>
+ </form>
+ </div>
+{% endblock %}