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 () { ...@@ -460,6 +460,7 @@ $(document).ready(function () {
}); });
} else { } else {
hideWaitingModal();
$('aside').removeClass("control-sidebar-open"); $('aside').removeClass("control-sidebar-open");
mssgModal({ mssgModal({
title : "No products were found!", title : "No products were found!",
......
...@@ -68,9 +68,10 @@ ...@@ -68,9 +68,10 @@
{% block user %}{% endblock %} {% block user %}{% endblock %}
</li> </li>
<!-- Control Sidebar Toggle Button --> <!-- Control Sidebar Toggle Button -->
<li> <li>{% if showcart %}
<a id="product-list-toggle" href="#" data-toggle="control-sidebar"><i <a id="product-list-toggle" href="#" data-toggle="control-sidebar"><i
class="fa fa-shopping-cart"></i></a> class="fa fa-shopping-cart"></i></a>
{% endif %}
</li> </li>
</ul> </ul>
</div> </div>
......
This diff is collapsed.
...@@ -34,6 +34,15 @@ ...@@ -34,6 +34,15 @@
</span> </span>
</a> </a>
</li> </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> <li>
<a class="treeview " href="{% url 'logout' %}?next={{ request.path }}"> <a class="treeview " href="{% url 'logout' %}?next={{ request.path }}">
<i class="fa fa-sign-out"></i> <i class="fa fa-sign-out"></i>
......
...@@ -16,7 +16,7 @@ import os ...@@ -16,7 +16,7 @@ import os
import sys import sys
from geosentinel import APISentinel, polygonToBox from geosentinel import APISentinel, polygonToBox
###########3 lee archivo de configuración ################ ########### lee archivo de configuración ################
dirname = os.path.dirname(__file__) dirname = os.path.dirname(__file__)
configfile = os.path.join(dirname, '../config/config.json') configfile = os.path.join(dirname, '../config/config.json')
...@@ -31,13 +31,14 @@ print(config['API_SENTINEL']['SENTINEL_PASS']) ...@@ -31,13 +31,14 @@ print(config['API_SENTINEL']['SENTINEL_PASS'])
NAS_PATH = config['PATHS']['PATH_NAS'] NAS_PATH = config['PATHS']['PATH_NAS']
USERS_PATH = config['PATHS']['PATH_USERS']
SENTINEL_PATH = config['PATHS']['PATH_GEOSENTINEL'] SENTINEL_PATH = config['PATHS']['PATH_GEOSENTINEL']
API_SENTINEL_USER = config['API_SENTINEL']['SENTINEL_USER'] 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) 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. # Create your views here.
...@@ -61,9 +62,9 @@ def map(request): ...@@ -61,9 +62,9 @@ def map(request):
View function for home page of site. View function for home page of site.
""" """
form = ASFSearchForm(request.POST) form = ASFSearchForm(request.POST)
showcart = True
# Render the HTML template index.html with the data in the context variable # 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): def requestToImage(request):
...@@ -104,7 +105,10 @@ def productList(request): ...@@ -104,7 +105,10 @@ def productList(request):
pol_bbox = polygonToBox.getWKTPolygonBoundingBox(area, True) pol_bbox = polygonToBox.getWKTPolygonBoundingBox(area, True)
## requesting producto to sentinel api ## 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 ## path from image preview storage location
img_preview = '/static/images/sat_preview/sat_test.jpg' img_preview = '/static/images/sat_preview/sat_test.jpg'
...@@ -451,8 +455,30 @@ def purchaseProduct(request): ...@@ -451,8 +455,30 @@ def purchaseProduct(request):
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def showCart(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---------------------- #---------------test process----------------------
print("showcart!!!") print("PAGAR!!!!")
user = User.objects.get(id=request.user.id) user = User.objects.get(id=request.user.id)
query = [] 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) 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): ...@@ -472,7 +498,9 @@ def showCart(request):
useremail = values['user__email'] 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): if not os.path.exists(userdir):
os.makedirs(userdir) os.makedirs(userdir)
...@@ -490,15 +518,11 @@ def showCart(request): ...@@ -490,15 +518,11 @@ def showCart(request):
data['productLevel'] = 'L2A' data['productLevel'] = 'L2A'
data['startDate'] = str(values['search__startDate'].date()).replace("-", "") #quita los guiones de la fecha 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['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['clouds'] = values['search__clouds']
# data['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
# data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
data['productsDir'] = products_dir data['productsDir'] = products_dir
data['linksDir'] = linksDir data['linksDir'] = linksDir
data['username'] = 'emmhp' data['username'] = API_SENTINEL_USER
data['password'] = 'geoemm29' data['password'] = API_SENTINEL_PASS
#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
...@@ -507,7 +531,9 @@ def showCart(request): ...@@ -507,7 +531,9 @@ def showCart(request):
#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)
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): ...@@ -530,9 +556,12 @@ def showCart(request):
#------------------------------------- #-------------------------------------
user = User.objects.get(id=request.user.id) user = User.objects.get(id=request.user.id)
prod_list = [] 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_price = 0
total_products = 0 total_products = 0
...@@ -543,7 +572,8 @@ def showCart(request): ...@@ -543,7 +572,8 @@ def showCart(request):
'price': products['price'], 'price': products['price'],
'aggreg_date': products['aggreg_date'], 'aggreg_date': products['aggreg_date'],
'catalog': product, 'catalog': product,
'id': products['id'] 'product_id': products['id'],
"process": products['search__process_id__name'],
}) })
total_price += products['price'] total_price += products['price']
total_products += 1 total_products += 1
......
{ {
"PATHS": { "PATHS": {
"PATH_GEOSENTINEL": "/home/david/centroGEO/repsat/Geosentinel", "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": { "API_SENTINEL": {
"SENTINEL_USER" : "emmhp", "SENTINEL_USER" : "emmhp",
......
/home/luis/django-apps/GeoSentinel/geosentinel ../GeoSentinel/geosentinel
\ No newline at end of file \ 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