Commit 3766eb83 authored by José Luis Uc's avatar José Luis Uc

Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev

parents 3fb0e478 e191223e
......@@ -460,6 +460,7 @@ $(document).ready(function () {
});
} else {
hideWaitingModal();
$('aside').removeClass("control-sidebar-open");
mssgModal({
title : "No products were found!",
......
......@@ -68,9 +68,10 @@
{% block user %}{% endblock %}
</li>
<!-- Control Sidebar Toggle Button -->
<li>
<li>{% if showcart %}
<a id="product-list-toggle" href="#" data-toggle="control-sidebar"><i
class="fa fa-shopping-cart"></i></a>
{% endif %}
</li>
</ul>
</div>
......
This diff is collapsed.
......@@ -34,6 +34,15 @@
</span>
</a>
</li>
<li>
<a class="treeview " href="{{ BASE_URL }}/catalog/cart">
<i class="fa fa-shopping-cart"></i>
<span>View shopping cart</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
<li>
<a class="treeview " href="{% url 'logout' %}?next={{ request.path }}">
<i class="fa fa-sign-out"></i>
......
......@@ -16,7 +16,7 @@ import os
import sys
from geosentinel import APISentinel, polygonToBox
###########3 lee archivo de configuración ################
########### lee archivo de configuración ################
dirname = os.path.dirname(__file__)
configfile = os.path.join(dirname, '../config/config.json')
......@@ -31,13 +31,14 @@ print(config['API_SENTINEL']['SENTINEL_PASS'])
NAS_PATH = config['PATHS']['PATH_NAS']
USERS_PATH = config['PATHS']['PATH_USERS']
SENTINEL_PATH = config['PATHS']['PATH_GEOSENTINEL']
API_SENTINEL_USER = config['API_SENTINEL']['SENTINEL_USER']
API_SENTINEL_PATH = config['API_SENTINEL']['SENTINEL_PASS']
API_SENTINEL_PASS = config['API_SENTINEL']['SENTINEL_PASS']
###########################################################
sys.path.append(SENTINEL_PATH)
sentinel = APISentinel.APISentinel(API_SENTINEL_USER, API_SENTINEL_PATH)
sentinel = APISentinel.APISentinel(API_SENTINEL_USER, API_SENTINEL_PASS)
# Create your views here.
......@@ -61,9 +62,9 @@ def map(request):
View function for home page of site.
"""
form = ASFSearchForm(request.POST)
showcart = True
# Render the HTML template index.html with the data in the context variable
return render(request, 'map.html', { "searchForm": form })
return render(request, 'map.html', { "searchForm": form,"showcart": showcart })
#-------------------------------------------------------------------------------
def requestToImage(request):
......@@ -104,7 +105,10 @@ def productList(request):
pol_bbox = polygonToBox.getWKTPolygonBoundingBox(area, True)
## requesting producto to sentinel api
products = sentinel.getProducts(pol_bbox, date, params)
##products = sentinel.getProducts(pol_bbox, date, params)
products = sentinel.getProducts(pol_bbox, date, {"platformname":"Sentinel-2", "cloudcoverpercentage":cloud_percentage}, "Contains") ##intenta obtener los productos que contienen el polígono
if len(products)<=0:
products = sentinel.getProducts(pol_bbox, date, {"platformname":"Sentinel-2", "cloudcoverpercentage":cloud_percentage}) ## si no hay que contengan el polígono busca los que lo intersecan
## path from image preview storage location
img_preview = '/static/images/sat_preview/sat_test.jpg'
......@@ -451,8 +455,30 @@ def purchaseProduct(request):
#-------------------------------------------------------------------------------
def showCart(request):
user = User.objects.get(id=request.user.id)
prod_list = []
product_list = Purchase.objects.values('user', 'productList', 'purchased', 'price', 'aggreg_date').filter(user=user, purchased=0)
total_price = 0
total_products = 0
for products in product_list:
product = json.loads(products['productList'])
prod_list.append({
'purchased': products['purchased'],
'price': products['price'],
'aggreg_date': products['aggreg_date'],
'catalog': product
})
total_price += products['price']
total_products += 1
return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products})
#-------------------------------------
def Pay (request):
#---------------test process----------------------
print("showcart!!!")
print("PAGAR!!!!")
user = User.objects.get(id=request.user.id)
query = []
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)
......@@ -472,7 +498,9 @@ def showCart(request):
useremail = values['user__email']
userdir = NAS_PATH + "repsat_test_dev/"+useremail ##crea el directorio del usuario
#userdir = NAS_PATH + "repsat_test_dev/"+useremail ##crea el directorio del usuario
userdir = USERS_PATH + useremail
if not os.path.exists(userdir):
os.makedirs(userdir)
......@@ -490,15 +518,11 @@ def showCart(request):
data['productLevel'] = 'L2A'
data['startDate'] = str(values['search__startDate'].date()).replace("-", "") #quita los guiones de la fecha
data['endDate'] = str(values['search__endDate'].date()).replace("-", "") #quita los guiones de la fecha
# data['startDate'] = request.POST['startDate']
# data['endDate'] = request.POST['endDate']
data['clouds'] = values['search__clouds']
# data['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
# data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
data['productsDir'] = products_dir
data['linksDir'] = linksDir
data['username'] = 'emmhp'
data['password'] = 'geoemm29'
data['username'] = API_SENTINEL_USER
data['password'] = API_SENTINEL_PASS
#json_data = json.dumps(data, indent=4,sort_keys=True)
#formatea el json
......@@ -507,7 +531,9 @@ def showCart(request):
#escribe el json en el archivo
fidProductsFile = open(search_dir+"/findProducts.json", "w")
fidProductsFile.write(json_data)
fidProductsFile.close()
fidProductsFile.close()
os.system("L2ASCL_AreaProcessing.sh "+search_dir+"/ 1 > "+search_dir+"/L2ASCL_AreaProcessing.log") ###ejecuta el proceso
......@@ -530,9 +556,12 @@ def showCart(request):
#-------------------------------------
user = User.objects.get(id=request.user.id)
prod_list = []
product_list = Purchase.objects.values('user', 'productList', 'purchased', 'price', 'aggreg_date', 'id').filter(user=user, purchased=0)
product_list = Purchase.objects.values('id','user', 'productList', 'purchased', 'price', 'aggreg_date','search__process_id__name').filter(user=user, purchased=0)
total_price = 0
total_products = 0
......@@ -543,7 +572,8 @@ def showCart(request):
'price': products['price'],
'aggreg_date': products['aggreg_date'],
'catalog': product,
'id': products['id']
'product_id': products['id'],
"process": products['search__process_id__name'],
})
total_price += products['price']
total_products += 1
......
{
"PATHS": {
"PATH_GEOSENTINEL": "/home/david/centroGEO/repsat/Geosentinel",
"PATH_NAS": "/home/david/NAS/"
"PATH_NAS": "/home/david/NAS/",
"PATH_USERS" : "/home/david/NAS/repsat_test_dev/"
},
"API_SENTINEL": {
"SENTINEL_USER" : "emmhp",
......
/home/luis/django-apps/GeoSentinel/geosentinel
\ No newline at end of file
../GeoSentinel/geosentinel
\ No newline at end of file
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