[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-codeless] branch master updated: error handling impr
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-codeless] branch master updated: error handling improved |
Date: |
Mon, 09 Jul 2018 22:18:04 +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 6e43119 error handling improved
6e43119 is described below
commit 6e43119342e68812a1fb7d2f735c5478262a9ae6
Author: shivam kohli <address@hidden>
AuthorDate: Tue Jul 10 01:47:35 2018 +0530
error handling improved
---
inventory/migrations/0002_auto_20180709_1228.py | 19 ++++++++++++++
inventory/views.py | 34 ++++++++++++++++++++-----
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/inventory/migrations/0002_auto_20180709_1228.py
b/inventory/migrations/0002_auto_20180709_1228.py
new file mode 100644
index 0000000..ffcccd9
--- /dev/null
+++ b/inventory/migrations/0002_auto_20180709_1228.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('inventory', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='order',
+ name='product_id',
+ field=models.ManyToManyField(blank=True, to='inventory.Product'),
+ ),
+ ]
diff --git a/inventory/views.py b/inventory/views.py
index 681009d..88f7199 100644
--- a/inventory/views.py
+++ b/inventory/views.py
@@ -40,7 +40,19 @@ from django.http import JsonResponse
def fulfillment(request):
- return render(request, 'inventory/fulfillment.html')
+ order_id = request.GET.get('order_id')
+ if order_id is None:
+ return HttpResponse("Error while loading the page")
+ order_instance = Order.objects.get(order_id=order_id)
+ product = order_instance.product_id.all()
+ for item in range(len(product)):
+ if product[item].document:
+ filename = product[item].document.file.name.split('/')[-1]
+ response = HttpResponse(product[item].document.file,
content_type='application/pdf')
+ response['Content-Disposition'] = 'inline; filename=%s' % filename
+ return response
+ else:
+ return render(request, 'inventory/fulfillment.html')
def shipment(request):
@@ -106,7 +118,7 @@ def pay(request):
def payment(request):
- # session_id = request.session.session_key
+ session_id = request.session.session_key
name = request.GET.get('name')
price = request.GET.get('price')
merchant = request.GET.get('merchant')
@@ -139,15 +151,25 @@ def payment(request):
)
)
order_resp = backend_post("order", order)
+ try:
+ order_id = order_resp["order_id"]
+ except Exception as e:
+ return HttpResponse("Please refresh and try again")
# Checking Payment Status and Prompting for Payment
pay_params = dict(
instance="default",
- order_id=order_resp["order_id"],
- # session_id=session_id,
+ order_id=order_id,
+ session_id=session_id,
)
pay_status = backend_get("check-payment", pay_params)
- payment_redirect_url = pay_status["payment_redirect_url"]
- return redirect(payment_redirect_url)
+ if pay_status["paid"]:
+ base_url = request.build_absolute_uri().rsplit('/', 1)[0]
+ url = base_url+"/fulfillment?order_id="+order_resp["order_id"]
+ return redirect(url)
+ else:
+ if pay_status["payment_redirect_url"]:
+ payment_redirect_url = pay_status["payment_redirect_url"]
+ return redirect(payment_redirect_url)
def backend_get(endpoint, params):
--
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: error handling improved,
gnunet <=