Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
72153411
Commit
72153411
authored
Feb 08, 2019
by
Irving David
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prueba de ejecución de proceso al hacer clic en el botón pay
parent
a6c297b5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
35 deletions
+41
-35
views.py
catalog/views.py
+39
-34
config.json
config/config.json
+2
-1
No files found.
catalog/views.py
View file @
72153411
...
@@ -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_PA
TH
=
config
[
'API_SENTINEL'
][
'SENTINEL_PASS'
]
API_SENTINEL_PA
SS
=
config
[
'API_SENTINEL'
][
'SENTINEL_PASS'
]
###########################################################
###########################################################
sys
.
path
.
append
(
SENTINEL_PATH
)
sys
.
path
.
append
(
SENTINEL_PATH
)
sentinel
=
APISentinel
.
APISentinel
(
API_SENTINEL_USER
,
API_SENTINEL_PA
TH
)
sentinel
=
APISentinel
.
APISentinel
(
API_SENTINEL_USER
,
API_SENTINEL_PA
SS
)
# Create your views here.
# Create your views here.
...
@@ -454,8 +455,30 @@ def purchaseProduct(request):
...
@@ -454,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
)
...
@@ -475,7 +498,9 @@ def showCart(request):
...
@@ -475,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
)
...
@@ -493,15 +518,11 @@ def showCart(request):
...
@@ -493,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
...
@@ -512,6 +533,8 @@ def showCart(request):
...
@@ -512,6 +533,8 @@ def showCart(request):
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
#~ user = User.objects.get(id=request.user.id)
#~ user = User.objects.get(id=request.user.id)
...
@@ -533,26 +556,8 @@ def showCart(request):
...
@@ -533,26 +556,8 @@ 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
):
Purchase
.
objects
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
0
)
.
update
(
purchased
=
True
)
Purchase
.
objects
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
0
)
.
update
(
purchased
=
True
)
return
redirect
(
'../../reports'
)
return
redirect
(
'../../reports'
)
config/config.json
View file @
72153411
{
{
"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"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment