[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant-frontends] branch master updated: Starting
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant-frontends] branch master updated: Starting separation of backoffice between blog and donations. |
Date: |
Fri, 24 Feb 2017 16:01:26 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant-frontends.
The following commit(s) were added to refs/heads/master by this push:
new af9dd7c Starting separation of backoffice between blog and donations.
af9dd7c is described below
commit af9dd7c328dd02c4be845e2e7f3dbb014a7a4a9c
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Feb 24 16:01:00 2017 +0100
Starting separation of backoffice between blog and donations.
---
talerfrontends/blog/blog.py | 32 +++++++++++++---
talerfrontends/blog/static/backoffice.js | 55 +++++++++++++++++++++++++++
talerfrontends/blog/templates/backoffice.html | 11 ++++++
talerfrontends/common_routes.py | 7 ----
4 files changed, 93 insertions(+), 12 deletions(-)
diff --git a/talerfrontends/blog/blog.py b/talerfrontends/blog/blog.py
index dd463e4..3f0e745 100644
--- a/talerfrontends/blog/blog.py
+++ b/talerfrontends/blog/blog.py
@@ -29,7 +29,8 @@ import base64
import random
import time
import json
-from talerfrontends.common_routes import tracking, history
+import datetime
+from talerfrontends.common_routes import tracking
from pprint import pprint
from talerfrontends.talerconfig import TalerConfig
from talerfrontends.helpers import (make_url, frontend_common,
@@ -135,7 +136,7 @@ def article(name, data=None):
return response
address@hidden('/pay', methods=["POST"])
address@hidden("/pay", methods=["POST"])
def pay():
deposit_permission = flask.request.get_json()
if deposit_permission is None:
@@ -147,12 +148,33 @@ def pay():
return r.text, r.status_code
- proposal_data = r.json()['proposal_data']
- article_name = proposal_data['extra']['article_name']
+ proposal_data = r.json()["proposal_data"]
+ article_name = proposal_data["extra"]["article_name"]
payed_articles = flask.session["payed_articles"] =
flask.session.get("payed_articles", [])
if article_name not in payed_articles:
payed_articles.append(article_name)
return r.text, 200
-app.add_url_rule('/history', 'history', history)
address@hidden("/history")
+def history():
+ days = expect_parameter_int("days")
+ instance = expect_parameter("instance")
+ date = datetime.datetime.fromtimestamp(0)
+ if 0 != days:
+ now = datetime.date.today()
+ d = datetime.timedelta(days=days)
+ date = now - d
+ url = urljoin(BACKEND_URL, "history")
+ r = requests.get(url, params=dict(date=date.strftime("%s"),
instance=instance))
+ if r.status_code != 200:
+ logger.error("failed to GET to '%s'", url)
+ raise BackendError(r.status_code, r.text)
+ return r.text
+
+
address@hidden("/backoffice")
+def track():
+ # return minimal HTML+JavaScript for calling /history
+ response =
flask.make_response(flask.render_template("templates/backoffice.html"))
+ return response
diff --git a/talerfrontends/blog/static/backoffice.js
b/talerfrontends/blog/static/backoffice.js
new file mode 100644
index 0000000..23f43c4
--- /dev/null
+++ b/talerfrontends/blog/static/backoffice.js
@@ -0,0 +1,55 @@
+/*
+ @licstart The following is the entire license notice for the
+ JavaScript code in this page.
+
+ Copyright (C) 2015, 2016 INRIA
+
+ The JavaScript code in this page is free software: you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License (GNU LGPL) as published by the Free Software
+ Foundation, either version 2.1 of the License, or (at your option)
+ any later version. The code is distributed WITHOUT ANY WARRANTY;
+ without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU LGPL for more details.
+
+ As additional permission under GNU LGPL version 2.1 section 7, you
+ may distribute non-source (e.g., minimized or compacted) forms of
+ that code without the copy of the GNU LGPL normally required by
+ section 4, provided you include this license notice and a URL
+ through which recipients can access the Corresponding Source.
+
+ @licend The above is the entire license notice
+ for the JavaScript code in this page.
+
+ @brief Contains functions that regulate the focus to input fields
+ and others that request /history to the frontend
+ @author Marcello Stanisci
+*/
+"use strict";
+
+function get_history(){
+ var DAYS = 10;
+ var INSTANCE = "FSF";
+ var req = new XMLHttpRequest();
+ req.open("GET", `/history?days=${DAYS}&instance=${INSTANCE}`, true);
+ req.onload = function(){
+ if(req.readyState == 4 && req.status == 200){
+ var history = JSON.parse(req.responseText);
+ if(!history)
+ console.log("Got invalid JSON");
+ if(0 == history.length){
+ console.log("Got no transactions");
+ }
+ for (var i=0; i<history.length; i++){
+ var entry = history[i];
+ console.log(`Order id: ${entry.order_id}`);
+ }
+ }
+ else{
+ console.log("error: status != 200");
+ }
+ }
+ req.send();
+}
+
+document.addEventListener("DOMContentLoaded", get_history);
diff --git a/talerfrontends/blog/templates/backoffice.html
b/talerfrontends/blog/templates/backoffice.html
new file mode 100644
index 0000000..cf8101e
--- /dev/null
+++ b/talerfrontends/blog/templates/backoffice.html
@@ -0,0 +1,11 @@
+{% extends "templates/base.html" %}
+{% block main %}
+ <h1>Backoffice</h1>
+ <p>This page simulates a backoffice facility. Through it,
+ the user can see the money flow from Taler transactions to
+ wire transfers and viceversa.</p>
+{% endblock main %}
+
+{% block scripts %}
+ <script src="{{ url('/static/backoffice.js') }}"
type="application/javascript"></script>
+{% endblock scripts %}
diff --git a/talerfrontends/common_routes.py b/talerfrontends/common_routes.py
index a416010..ee1b930 100644
--- a/talerfrontends/common_routes.py
+++ b/talerfrontends/common_routes.py
@@ -33,13 +33,6 @@ def custom_error():
body = json.loads(error.decode("utf-8"))
raise CustomError(body['code'], body['hint'], body['status'])
address@hidden('/history')
-def history():
- days = expect_parameter_int("days")
- ret = get_history(days)
- return ret
-
-
@frontend_common.route('/map')
def map_contract():
h_contract = expect_parameter("h_contract")
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant-frontends] branch master updated: Starting separation of backoffice between blog and donations.,
gnunet <=