gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: G


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: Going on with Python tutorial..
Date: Mon, 20 Feb 2017 20:02:59 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository merchant-frontend-examples.

The following commit(s) were added to refs/heads/master by this push:
     new 2030c9e  Going on with Python tutorial..
2030c9e is described below

commit 2030c9eee0970f17798dea700cb21027b3f7a6f3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Feb 20 20:02:19 2017 +0100

    Going on with Python tutorial..
---
 Python/Makefile                                    |   4 +-
 Python/{ => lib}/pytaler/__init__.py               |   0
 .../lib/pytaler/__pycache__/amounts.cpython-35.pyc | Bin 0 -> 1272 bytes
 Python/{ => lib}/pytaler/amounts.py                |   0
 Python/lib/pytaler/tests.py                        |  26 +++++++++++
 Python/{ => lib}/setup.py                          |   0
 Python/tutorial.py                                 |   6 ---
 .../tutorial/__pycache__/tutorial.cpython-35.pyc   | Bin 0 -> 602 bytes
 Python/tutorial/templates/index.html               |  12 +++++
 Python/tutorial/tutorial.py                        |  49 +++++++++++++++++++++
 10 files changed, 89 insertions(+), 8 deletions(-)

diff --git a/Python/Makefile b/Python/Makefile
index ec2ca0f..a565c6d 100644
--- a/Python/Makefile
+++ b/Python/Makefile
@@ -1,5 +1,5 @@
 all:
-       pip3 install . --install-option="--prefix=$(TALER_PREFIX)"
+       pip3 install lib --install-option="--prefix=$(TALER_PREFIX)"
 
 check:
-       python3 pytaler/tests.py
+       python3 lib/pytaler/tests.py
diff --git a/Python/pytaler/__init__.py b/Python/lib/pytaler/__init__.py
similarity index 100%
rename from Python/pytaler/__init__.py
rename to Python/lib/pytaler/__init__.py
diff --git a/Python/lib/pytaler/__pycache__/amounts.cpython-35.pyc 
b/Python/lib/pytaler/__pycache__/amounts.cpython-35.pyc
new file mode 100644
index 0000000..24b724e
Binary files /dev/null and 
b/Python/lib/pytaler/__pycache__/amounts.cpython-35.pyc differ
diff --git a/Python/pytaler/amounts.py b/Python/lib/pytaler/amounts.py
similarity index 100%
rename from Python/pytaler/amounts.py
rename to Python/lib/pytaler/amounts.py
diff --git a/Python/lib/pytaler/tests.py b/Python/lib/pytaler/tests.py
new file mode 100644
index 0000000..120e968
--- /dev/null
+++ b/Python/lib/pytaler/tests.py
@@ -0,0 +1,26 @@
+import unittest
+import amounts
+from random import randint
+
+currency = "KUDOS"
+
+class AmountsTest(unittest.TestCase):
+
+    def test(self):
+        a1 = amounts.amount_get_zero(currency)
+        a2 = amounts.amount_get_zero(currency)
+        v1 = randint(1, 200)
+        v2 = randint(1, 200)
+        f1 = randint(10000000, 100000000)
+        f2 = randint(10000000, 100000000)
+        a1['value'] = v1
+        a2['value'] = v2
+        a1['fraction'] = f1
+        a2['fraction'] = f2
+        res1 = amounts.amount_sum(a1, a2)
+        res2 = amounts.amount_sub(res1, a1)
+        self.assertTrue(amounts.same_amount(res2, a2))
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/Python/setup.py b/Python/lib/setup.py
similarity index 100%
rename from Python/setup.py
rename to Python/lib/setup.py
diff --git a/Python/tutorial.py b/Python/tutorial.py
deleted file mode 100644
index d82c51f..0000000
--- a/Python/tutorial.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from flask import Flask
-app = Flask(__name__)
-
address@hidden('/')
-def hello_world():
-    return 'Hello, World!'
diff --git a/Python/tutorial/__pycache__/tutorial.cpython-35.pyc 
b/Python/tutorial/__pycache__/tutorial.cpython-35.pyc
new file mode 100644
index 0000000..9b2dbeb
Binary files /dev/null and 
b/Python/tutorial/__pycache__/tutorial.cpython-35.pyc differ
diff --git a/Python/tutorial/templates/index.html 
b/Python/tutorial/templates/index.html
new file mode 100644
index 0000000..fa0a8f4
--- /dev/null
+++ b/Python/tutorial/templates/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+  <!-- This file is in the public domain -->
+  <head>
+    <title>A donation button</title>
+  </head>
+  <body>
+    <form action='/donate' method='GET'>
+      <input type='submit' value='Donate!'></input>
+    </form>
+  </body>
+</html>
diff --git a/Python/tutorial/tutorial.py b/Python/tutorial/tutorial.py
new file mode 100644
index 0000000..294af4a
--- /dev/null
+++ b/Python/tutorial/tutorial.py
@@ -0,0 +1,49 @@
+import flask
+app = flask.Flask(__name__)
+
address@hidden('/')
+def index():
+    return flask.render_template('index.html')
+
+
address@hidden('/donate')
+def donate():
+   resp = flask.Response()
+   resp.headers['X-Taler-Contract-Url'] = '/generate-contract'
+   return resp
+
+
address@hidden('/generate-contract')
+def generate_contract():
+    
+    # 1. Generate order.
+    # FIXME: pass to VALUE.FRACTION:CURRENCY notation.
+
+    donation_amount = amounts.amount_get_zero("KUDOS")
+
+    order = dict(
+        nonce=flask.request.args.get("nonce"),
+        amount=ARTICLE_AMOUNT,
+        max_fee=dict(value=1, fraction=0, currency=CURRENCY),
+        products=[
+            dict(
+                description="Essay: " + article_name.replace("_", " "),
+                quantity=1,
+                product_id=0,
+                price=ARTICLE_AMOUNT,
+            ),
+        ],
+        fulfillment_url=make_url("/essay/" + quote(article_name)),
+        merchant=dict(
+            instance=INSTANCE,
+            address="nowhere",
+            name="Kudos Inc.",
+            jurisdiction="none",
+        ),
+        extra=dict(article_name=article_name),
+    )
+
+
+
+    # 2. POST order to BE.
+    # 3. Relay proposal to client.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]