[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-codeless] branch master updated: added GNU style bui
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-codeless] branch master updated: added GNU style build and payment button |
Date: |
Sun, 01 Jul 2018 17:58:56 +0200 |
This is an automated email from the git hooks/post-receive script.
shivam-kohli pushed a commit to branch master
in repository codeless.
The following commit(s) were added to refs/heads/master by this push:
new cd3fdd5 added GNU style build and payment button
cd3fdd5 is described below
commit cd3fdd5d00fe2ce4b49a5cf3577fc7886e2fbf31
Author: shivam kohli <address@hidden>
AuthorDate: Sun Jul 1 21:28:44 2018 +0530
added GNU style build and payment button
---
.gitignore | 8 ++++++
Makefile.in | 35 +++++++++++++++++++++++
codeless/urls.py | 6 ++--
configure.ac | 24 ++++++++++++++++
inventory/views.py | 55 +++++++++++++++++++++++++++---------
requirements.txt | 2 ++
templates/inventory/fulfillment.html | 10 +++++++
templates/inventory/product.html | 10 +++++++
templates/inventory/test.html | 13 ---------
9 files changed, 133 insertions(+), 30 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8ad70e2..abee8ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,11 @@ inventory/migrations/__pycache__/*
inventory/__pycache__/.DS_Store
templates/.DS_Store
inventory/migrations/.DS_Store
+Makefile
+aclocal.m4
+autom4te.cache/
+config.log
+config.status
+configure
+install-sh
+missing
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..8918ed0
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,35 @@
+ACLOCAL_AMFLAGS = -I m4
+
+red=`tput setaf 1`
+green=`tput setaf 2`
+reset=`tput sgr0`
+
+.PHONY: installdjango
+installdjango:
+ @echo "${green}>>> Installing the Django${reset}"
+ @pip3 install django==1.8
+
+.PHONY: install
+install:
+ @pip3 install -U -r requirements.txt
+
+.PHONY: migrate
+migrate:
+ @./manage.py makemigrations
+ @./manage.py migrate
+
+.PHONY: createuser
+createuser:
+ @echo "${green}>>> Creating a 'admin' user ...${reset}"
+ @./manage.py createsuperuser --username='admin' --email=''
+
+.PHONY: run
+run:
+ @./manage.py runserver
+
+.PHONY: pyc-clean
+pyc-clean:
+ @find . -name "*.pyc" -exec rm -f {} \;
+
+Makefile: Makefile.in
+ ./config.status $@
diff --git a/codeless/urls.py b/codeless/urls.py
index e78e737..e0bf49c 100644
--- a/codeless/urls.py
+++ b/codeless/urls.py
@@ -8,9 +8,9 @@ urlpatterns = [
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
- url(r'^test/$', 'inventory.views.test', name='test'),
- url(r'^payment/$', 'inventory.views.payment', name='payment'),
- url(r'^payment/pay/$', 'inventory.views.pay', name='pay'),
+ url(r'^fulfillment/$', 'inventory.views.fulfillment', name='fulfillment'),
+ url(r'^payment$', 'inventory.views.payment', name='payment'),
+ url(r'^pay/$', 'inventory.views.pay', name='pay'),
url(r'^signup/$', 'inventory.views.signup', name='signup'),
url(r'^new_product/$', 'inventory.views.new_product', name='new_product'),
url(r'^add_product/$', 'inventory.views.add_product', name='add_product'),
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..36e94c8
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,24 @@
+AC_INIT([codeless], [1.0], address@hidden)
+
+AM_INIT_AUTOMAKE
+AC_PROG_AWK
+AC_PROG_SED
+
+filter_pkg_name() {
+ echo "$1" |sed 's/[^A-Za-z0-9_]//g'
+}
+
+AC_SUBST([mysite_pkg], [${PKG:-$PACKAGE}])
+
+AC_SUBST([mysite_db_name], [`filter_pkg_name $mysite_pkg`])
+AC_SUBST([mysite_db_user], [`filter_pkg_name $mysite_pkg`])
+AC_SUBST([mysite_db_passwd], [$DB_PASSWD])
+
+AC_SUBST([mysite_debug], [${DEBUG:-False}])
+
+AM_PATH_PYTHON([3],[:])
+AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
+
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
diff --git a/inventory/views.py b/inventory/views.py
index e050a1a..a5919fc 100644
--- a/inventory/views.py
+++ b/inventory/views.py
@@ -19,8 +19,8 @@ import json
from django.http import JsonResponse
-def test(request):
- return render(request, 'inventory/test.html')
+def fulfillment(request):
+ return render(request, 'inventory/fulfillment.html')
@csrf_exempt
@@ -35,18 +35,40 @@ def pay(request):
headers={"Authorization": "ApiKey sandbox"})
if r.status_code != 200:
return HttpResponse(r.status_code)
+ contract_terms = r.json()["contract_terms"]
+ print(contract_terms['products'])
+ for i in contract_terms['products']:
+ update_inventory(i["description"],i["quantity"])
return JsonResponse(r.json())
def payment(request):
session_id = request.session.session_key
+ # merchant_instance = User.objects.get(username=uid)
+ name = request.GET.get('name')
+ price = request.GET.get('price')
+ merchant = request.GET.get('merchant')
+ summary = name+' purchased from '+merchant
+ base_url = request.build_absolute_uri().rsplit('/', 1)[0]
# Creating an Order for a Payment
- order = dict(order=dict(amount="KUDOS:0.1",
- summary="codeless",
- instance="default",
- extra=dict(article_name="test"),
- fulfillment_url="https://example.com/thanks.html",
- pay_url="http://localhost:8000/payment/pay/",
+ order = dict(order=dict(amount="KUDOS:"+price,
+ summary=summary,
+ products=[
+ dict(
+ description=name,
+ quantity=1,
+ product_id=1,
+ price="KUDOS:"+price,
+ ),
+ ],
+ fulfillment_url=base_url+"/fulfillment/",
+ pay_url=base_url+"/pay/",
+ merchant=dict(
+ address="test",
+ name=merchant,
+ jurisdiction="none",
+ instance="default",
+ ),
)
)
order_resp = backend_post("order", order)
@@ -96,6 +118,7 @@ def update_inventory(name, quantity):
product_instance = Product.objects.get(name=name)
inventory_on_hand = product_instance.inventory_on_hand - quantity
product_instance.inventory_on_hand = inventory_on_hand
+ product_instance.save()
@login_required
@@ -165,14 +188,18 @@ def add_product(request):
@login_required
def product(request, uid):
- product_instance = Product.objects.get_or_create(product_id=uid)[0]
+ product = Product.objects.get_or_create(product_id=uid)[0]
context_dict = {}
- context_dict['name'] = product_instance.name
- context_dict['description'] = product_instance.description
- context_dict['price'] = product_instance.price
- context_dict['inventory_on_hand'] = product_instance.inventory_on_hand
- url_update_inventory = str('/update_stock/') + product_instance.name
+ context_dict['name'] = product.name
+ context_dict['description'] = product.description
+ context_dict['price'] = product.price
+ context_dict['inventory_on_hand'] = product.inventory_on_hand
+ url_update_inventory = str('/update_stock/') + product.name
context_dict['url_update_inventory'] = url_update_inventory
+ base_url = request.build_absolute_uri().rsplit('/', 3)[0]
+ merchant = request.user.username
+ parameters =
"name="+product.name+'&price='+product.price+'&merchant='+merchant
+ context_dict['href'] = base_url + "/payment?"+parameters
return render(request, 'inventory/product.html', context_dict)
diff --git a/requirements.txt b/requirements.txt
new file mode 100755
index 0000000..50dd46d
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+Django==1.8
+requests
\ No newline at end of file
diff --git a/templates/inventory/fulfillment.html
b/templates/inventory/fulfillment.html
new file mode 100644
index 0000000..76ed449
--- /dev/null
+++ b/templates/inventory/fulfillment.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+</head>
+<body>
+Thank you for purchasing.
+</form>
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/inventory/product.html b/templates/inventory/product.html
index a665876..778f490 100644
--- a/templates/inventory/product.html
+++ b/templates/inventory/product.html
@@ -67,6 +67,16 @@
<h1 style="text-transform: uppercase;" id="name">{{ name }}</h1>
</center>
+ <h5 color="black">The code for the pay now button is:</h5>
+
+ <xmp style="font-size: 50% ">
+ <a href="{{ href }}" style="text-decoration: none;"
onmouseover="this.style.textDecoration = 'underline'"
onmouseout="this.style.textDecoration = 'none'">buy now</a>
+ </xmp>
+
+ <h5 color="black">The above code would look like(click to perform the
payment):</h5>
+ <a href="{{ href }}" style="text-decoration: none;"
onmouseover="this.style.textDecoration = 'underline'"
onmouseout="this.style.textDecoration = 'none'">buy now</a>
+
+
<h5 color="black">Description:</h5><h6>{{ description }}</h6><br>
<h5 color="black">Price:</h5><h6>{{ price }}</h6><br>
<h5 color="black">The Cuurent Inventory on Hand is:- {{ inventory_on_hand
}}</h5>
diff --git a/templates/inventory/test.html b/templates/inventory/test.html
deleted file mode 100644
index d9db3b0..0000000
--- a/templates/inventory/test.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title></title>
-</head>
-<body>
-make payment
-<form name="Payment" action="/payment/" method="post"
enctype="multipart/form-data">
- {% csrf_token %}
- <button name="Payment" type="submit" class="submit">Payment</button>
-</form>
-</body>
-</html>
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-codeless] branch master updated: added GNU style build and payment button,
gnunet <=