- activacion del boton 'Pay'

- se muestra el proceso en la lista de reportes
parent bc00fc8c
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td><button type="button" name="pay" id="pay" class="btn btn-primary">Pay</button></td> <td><a href="../pay" class="btn btn-primary">Pay</a></td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
......
...@@ -14,4 +14,5 @@ urlpatterns = [ ...@@ -14,4 +14,5 @@ urlpatterns = [
url(r'^delcartrqst/$', views.delFromCart, name='del-cart-rqst'), url(r'^delcartrqst/$', views.delFromCart, name='del-cart-rqst'),
url(r'^purchcartrqst/$', views.purchaseProduct, name='purch-prod-rqst'), url(r'^purchcartrqst/$', views.purchaseProduct, name='purch-prod-rqst'),
url(r'^cart/$', views.showCart, name='show-cart'), url(r'^cart/$', views.showCart, name='show-cart'),
url(r'^pay/$', views.Pay, name='pay'),
] ]
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.shortcuts import render from django.shortcuts import render, redirect
from catalog.forms import ASFSearchForm from catalog.forms import ASFSearchForm
from catalog.models import Polygon, CartProduct, Product_l1c, Search, Purchase, Process from catalog.models import Polygon, CartProduct, Product_l1c, Search, Purchase, Process
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
...@@ -440,18 +440,19 @@ def showCart(request): ...@@ -440,18 +440,19 @@ def showCart(request):
print("showcart!!!") print("showcart!!!")
user = User.objects.get(id=request.user.id) user = User.objects.get(id=request.user.id)
query = [] query = []
query = Purchase.objects.values('search__area','user','user__username','user__email', 'search_id', 'search__clouds','search__startDate','search__endDate').filter(user=user, purchased=0) query = Purchase.objects.values('id','search__area','user','user__username','user__email', 'search_id', 'search__clouds','search__startDate','search__endDate').filter(user=user, purchased=0)
for values in query: for values in query:
print(values['user__username'])
print(values['user__email']) #print(values['user__username'])
print(values['search_id']) #print(values['user__email'])
print(str(values['search__startDate'].date()).replace("-", "")) #print(values['search_id'])
print(str(values['search__endDate'].date()).replace("-", "")) #print(str(values['search__startDate'].date()).replace("-", ""))
print(values['search__clouds']) #print(str(values['search__endDate'].date()).replace("-", ""))
print(values['search__area']) #print(values['search__clouds'])
#print(values['search__area'])
print(values['id'])
username = values['user__username'] username = values['user__username']
useremail = values['user__email'] useremail = values['user__email']
...@@ -487,7 +488,7 @@ def showCart(request): ...@@ -487,7 +488,7 @@ def showCart(request):
#json_data = json.dumps(data, indent=4,sort_keys=True) #json_data = json.dumps(data, indent=4,sort_keys=True)
#formatea el json #formatea el json
json_data = json.dumps(data, indent=4) json_data = json.dumps(data, indent=4)
print(json_data) #print(json_data)
#escribe el json en el archivo #escribe el json en el archivo
fidProductsFile = open(search_dir+"/findProducts.json", "w") fidProductsFile = open(search_dir+"/findProducts.json", "w")
fidProductsFile.write(json_data) fidProductsFile.write(json_data)
...@@ -532,3 +533,8 @@ def showCart(request): ...@@ -532,3 +533,8 @@ def showCart(request):
total_products += 1 total_products += 1
return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products}) return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products})
#-------------------------------------
def Pay (request):
Purchase.objects.filter(user_id=request.user.id, purchased=0).update(purchased=True)
return redirect('../../reports')
\ No newline at end of file
...@@ -64,12 +64,14 @@ def report_L2ASCL(request, report,purchase_id): ...@@ -64,12 +64,14 @@ def report_L2ASCL(request, report,purchase_id):
def Reports(request): def Reports(request):
productList=[] productList=[]
product_list = Purchase.objects.values('id','productList','aggreg_date','search__clouds' ,'search__startDate', 'search__endDate').filter(user_id=request.user.id, purchased=1) product_list = Purchase.objects.values('id','productList','aggreg_date','search__clouds' ,'search__startDate', 'search__endDate','search__process_id__name').filter(user_id=request.user.id, purchased=1)
print(product_list)
for producto in product_list: for producto in product_list:
size = 0 size = 0
for p in json.loads(producto['productList']): for p in json.loads(producto['productList']):
size = size + float(p['info']['size'][:-3]) size = size + float(p['info']['size'][:-3])
productList.append({ productList.append({
"process" : producto['search__process_id__name'],
"purchase_date": producto['aggreg_date'], "purchase_date": producto['aggreg_date'],
"startDate": producto['search__startDate'], "startDate": producto['search__startDate'],
"endDate": producto['search__endDate'], "endDate": producto['search__endDate'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment