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>
......
......@@ -2,26 +2,26 @@
{% load staticfiles %}
{% block headMedia %}
<link rel="stylesheet" href="{% static 'catalog/css/map.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/body.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/modal1.css' %}" type="text/css">
<!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">-->
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css">
<link rel="stylesheet" href="{% static 'catalog/css/map.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/body.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/modal1.css' %}" type="text/css">
<!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">-->
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<!-- <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>-->
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<!-- <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>-->
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<script src="{% static 'catalog/js/openLayers4.js' %}"></script>
<script src="{% static 'catalog/js/sidtMap.js' %}"></script>
<script src="{% static 'catalog/js/openLayers4.js' %}"></script>
<script src="{% static 'catalog/js/sidtMap.js' %}"></script>
{% endblock %}
{% block messages %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span>
</a>
<ul class="dropdown-menu">
</a>
<ul class="dropdown-menu">
<li class="header">You have 4 messages</li>
<li>
<!-- inner menu: contains the actual data -->
......@@ -54,14 +54,14 @@
</ul>
</li>
<li class="footer"><a href="#">See All Messages</a></li>
</ul>
</ul>
{% endblock %}
{% block notifications %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span>
</a>
<ul class="dropdown-menu">
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- inner menu: contains the actual data -->
......@@ -76,14 +76,14 @@
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</ul>
{% endblock %}
{% block tasks %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span>
</a>
<ul c{% load static %}lass="dropdown-menu">
</a>
<ul c{% load static %}lass="dropdown-menu">
<li class="header">You have 9 tasks</li>
<li>
<!-- inner menu: contains the actual data -->
......@@ -108,10 +108,10 @@
<li class="footer">
<a href="#">View all tasks</a>
</li>
</ul>
</ul>
{% endblock %}
{% block sidebar %}
<div class="form-group">
<div class="form-group">
<br>
<ul class="sidebar-menu" data-widget="tree">
<li>
......@@ -124,16 +124,16 @@
</a>
</li>
</ul>
</div>
<!-- form-group-->
</div>
<!-- form-group-->
{% endblock %}
{% block user %}
{% include "user_button.html" %}
{% include "user_button.html" %}
{% endblock %}
{% block content %}
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<div id="cartPage" class="wrapper" style="background-color: #ecf0f5">
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<div id="cartPage" class="wrapper" style="background-color: #ecf0f5">
<div class="text-center"><h1>Shopping Cart</h1></div>
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
......@@ -148,7 +148,7 @@
{% for product in product_list %}
<div class="box box-warning" style="margin-bottom: 10px">
<div class="box-header with-border">
<h3 class="box-title">Product {{ product.aggreg_date }}</h3>
<h3 class="box-title">{{ product.process }}: {{ product.aggreg_date }}</h3>
<div class="box-tools pull-right">
<span class="badge bg-green">Price ${{ product.price }}</span>
<button type="button" class="btn btn-box-tool" data-widget="collapse">
......@@ -201,7 +201,39 @@
</tbody>
<tfoot>
<tr>
<td><a href="../pay" class="btn btn-primary">Pay</a></td>
<td>
<a href="../pay" class="btn btn-primary pull-right">Pay</a>
</td>
<td>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="ulisexmorales-facilitator@gmail.com">
<input type="hidden" name="currency_code" value="MXN">
{% for product in product_list %}
<input type="hidden" name="item_name_{{forloop.counter}}"
value="{{product.process}}: {{ product.aggreg_date }}">
<input type="hidden" name="amount_{{forloop.counter}}"
value="{{ product.price }}">
<input type="hidden" name="item_number_{{forloop.counter}}"
value="{{ product.product_id }}">
{% endfor %}
<input type='hidden' name='cancel_return'
value='http://www.example.com/cancel.php'>
<input type='hidden' name='return'
value='http://www.example.com/success.php'>
<input type="image"
src="https://www.sandbox.paypal.com/es_XC/MX/i/btn/btn_buynowCC_LG.gif"
border="0" name="submit"
alt="PayPal, la forma más segura y rápida de pagar en línea.">
<img alt="" border="0"
src="https://www.sandbox.paypal.com/es_XC/i/scr/pixel.gif" width="1"
height="1">
</form>
</td>
</tr>
</tfoot>
</table>
......@@ -213,9 +245,9 @@
</div>
</section>
<!-- /.content -->
</div>
<!-- Footer -->
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute">
</div>
<!-- Footer -->
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute">
<!-- Footer Elements -->
<div class="container">
<!-- Social buttons
......@@ -258,9 +290,9 @@
<!-- Copyright -->
</footer>
<!-- Footer -->
<!-- Footer -->
<!-- /.content -->
<!-- /.content -->
{% endblock %}
{% block scripts %}
<!-- page script -->
......
......@@ -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
......@@ -509,6 +533,8 @@ def showCart(request):
fidProductsFile.write(json_data)
fidProductsFile.close()
os.system("L2ASCL_AreaProcessing.sh "+search_dir+"/ 1 > "+search_dir+"/L2ASCL_AreaProcessing.log") ###ejecuta el proceso
#~ user = User.objects.get(id=request.user.id)
......@@ -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