Commit f5991429 authored by Sergio Adrian Gongora Euan's avatar Sergio Adrian Gongora Euan
parents af79f7bd cbf128fb
...@@ -490,9 +490,10 @@ $(document).ready(function () { ...@@ -490,9 +490,10 @@ $(document).ready(function () {
'csrfmiddlewaretoken' : document.getElementsByName('csrfmiddlewaretoken')[0].value, 'csrfmiddlewaretoken' : document.getElementsByName('csrfmiddlewaretoken')[0].value,
'product_objects' : JSON.stringify(productObject), 'product_objects' : JSON.stringify(productObject),
'wkt' : $("#product-form input[name=polygon]").val(), 'wkt' : $("#product-form input[name=polygon]").val(),
'startDate' : $("#product-form input[name=start]").val(), 'startDate' : $("#product-form input[name=start]").val(),
'endDate' : $("#product-form input[name=end]").val(), 'endDate' : $("#product-form input[name=end]").val(),
'clouds' : $("#product-form input[name=cloudPercentage]").val(), 'clouds' : $("#product-form input[name=cloudPercentage]").val(),
'usuario' : $("#product-form input[name=user_name]").val()
}, },
dataType : 'json' dataType : 'json'
}); });
......
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
<!-- <form role="form" target="catalogFrame" action="{% url 'productList' %}" method="post"> --> <!-- <form role="form" target="catalogFrame" action="{% url 'productList' %}" method="post"> -->
<form id='product-form' role="form" method="post"> <form id='product-form' role="form" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" id="user_name" name="user_name" value={{user.get_username}}>
<ul class="sidebar-menu" data-widget="tree"> <ul class="sidebar-menu" data-widget="tree">
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
......
...@@ -12,12 +12,14 @@ from django.core import management ...@@ -12,12 +12,14 @@ from django.core import management
#from urllib import urlencode #from urllib import urlencode
#from collections import OrderedDict #from collections import OrderedDict
import requests, json, unicodedata, sys, base64 import requests, json, unicodedata, sys, base64
import os
import sys import sys
sys.path.append('../GeoSentinel/') sys.path.append('../GeoSentinel/')
from geosentinel import APISentinel, polygonToBox from geosentinel import APISentinel, polygonToBox
sentinel = APISentinel.APISentinel('emmhp', 'geoemm29') sentinel = APISentinel.APISentinel('emmhp', 'geoemm29')
NAS_PATH = '/home/david/NAS/'
# Create your views here. # Create your views here.
...@@ -268,17 +270,36 @@ def purchaseProduct(request): ...@@ -268,17 +270,36 @@ def purchaseProduct(request):
print(request.POST['startDate']) print(request.POST['startDate'])
print(request.POST['endDate']) print(request.POST['endDate'])
print(request.POST['clouds']) print(request.POST['clouds'])
print(request.POST['usuario'])
username = request.POST['usuario']
fecha_inicio = request.POST['startDate']
fecha_fin = request.POST['endDate']
print(fecha_inicio.replace("-", ""))
print(fecha_fin.replace("-", ""))
userdir = NAS_PATH + "repsat_test_dev/"+username ##crea el directorio del usuario
if not os.path.exists(userdir):
os.makedirs(userdir)
products_dir = NAS_PATH + "sentinelImages/L2A/"
linksDir = userdir+"/L2A/"
#obtiene los datos para el json #obtiene los datos para el json
data = {} data = {}
data['wkt'] = request.POST['wkt'] data['wkt'] = request.POST['wkt']
data['platform'] = 'Sentinel-2' data['platform'] = 'Sentinel-2'
data['productLevel'] = 'L2A' data['productLevel'] = 'L2A'
data['startDate'] = request.POST['startDate'] data['startDate'] = fecha_inicio.replace("-", "") #quita los guiones de la fecha
data['endDate'] = request.POST['endDate'] data['endDate'] = fecha_fin.replace("-", "") #quita los guiones de la fecha
#~ data['startDate'] = request.POST['startDate']
#~ data['endDate'] = request.POST['endDate']
data['clouds'] = request.POST['clouds'] data['clouds'] = request.POST['clouds']
data['productsDir'] = '/home/david/NAS/sentinelImages/L2A/' #~ data['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/' #~ data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
data['productsDir'] = products_dir
data['linksDir'] = linksDir
data['username'] = 'mario-chirinos' data['username'] = 'mario-chirinos'
data['password'] = 'r4nc0r4u' data['password'] = 'r4nc0r4u'
...@@ -287,7 +308,7 @@ def purchaseProduct(request): ...@@ -287,7 +308,7 @@ def purchaseProduct(request):
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("/home/david/centroGEO/repsat/GeoInt_SIDT/findProducts.json", "w") fidProductsFile = open(userdir+"/findProducts.json", "w")
fidProductsFile.write(json_data) fidProductsFile.write(json_data)
fidProductsFile.close() fidProductsFile.close()
......
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