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
96f8a1cd
Commit
96f8a1cd
authored
Feb 07, 2019
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev
parents
fc0afb58
58ce6932
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
295 additions
and
112 deletions
+295
-112
settings.py
GeoInt_SIDT/settings.py
+14
-1
admin.py
catalog/admin.py
+16
-0
forms.py
catalog/forms.py
+13
-6
0011_auto_20190206_2146.py
catalog/migrations/0011_auto_20190206_2146.py
+35
-9
0012_auto_20190206_1843.py
catalog/migrations/0012_auto_20190206_1843.py
+0
-43
0012_search_process.py
catalog/migrations/0012_search_process.py
+21
-0
models.py
catalog/models.py
+1
-2
body.css
catalog/static/catalog/css/body.css
+13
-2
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+18
-1
base_top.html
catalog/templates/base_top.html
+1
-1
map.html
catalog/templates/map.html
+1
-0
templates.html
catalog/templates/templates.html
+1
-0
urls.py
catalog/urls.py
+1
-0
views.py
catalog/views.py
+160
-47
db.sqlite3
db.sqlite3
+0
-0
No files found.
GeoInt_SIDT/settings.py
View file @
96f8a1cd
...
...
@@ -27,7 +27,7 @@ DEBUG = True
ALLOWED_HOSTS
=
[
'*'
]
DATA_UPLOAD_MAX_MEMORY_SIZE
=
500242880
#the post max is 500MB
# Application definition
INSTALLED_APPS
=
[
...
...
@@ -79,6 +79,17 @@ WSGI_APPLICATION = 'GeoInt_SIDT.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# 'NAME': 'repsatdb',
# 'USER': 'root',
# 'PASSWORD': 'root',
# 'HOST': 'localhost',
# 'PORT': '',
# }
# }
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
...
...
@@ -87,6 +98,8 @@ DATABASES = {
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
...
...
catalog/admin.py
View file @
96f8a1cd
...
...
@@ -3,4 +3,20 @@ from __future__ import unicode_literals
from
django.contrib
import
admin
# Las siguientes dos líneas evita el error: database is locked
from
django
import
db
db
.
connections
.
close_all
()
# Register your models here.
from
catalog.models
import
Process
from
catalog.models
import
Platform
#admin.site.register(Publisher)
class
ProcessAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'platform'
,
'productLevel'
)
admin
.
site
.
register
(
Process
,
ProcessAdmin
)
class
PlatformAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'acronym'
)
admin
.
site
.
register
(
Platform
,
PlatformAdmin
)
catalog/forms.py
View file @
96f8a1cd
# -*- coding: utf-8 -*-
from
django
import
forms
import
datetime
from
catalog.models
import
Process
# from django import db
# db.connections.close_all()
#from django.contrib.auth.forms import UserCreationForm
#from django.contrib.auth.models import User
#from buscador.models import Investigador, Reto
platforms
=
[
(
"sentinel2"
,
"Classification scene"
),
(
"waterBodies"
,
"Water bodies"
),
(
"urbanSprawl"
,
"Urban sprawl"
),
(
"vegIndex"
,
"Vegetation index"
)
]
all_process
=
Process
.
objects
.
all
()
platforms
=
[
]
for
each_process
in
all_process
:
platforms
.
append
((
each_process
.
platform_id
,
each_process
.
name
))
#ALOS, A3, AIRSAR, AS, ERS-1, E1, ERS-2, E2, JERS-1, J1, RADARSAT-1, R1, SEASAT, SS, Sentinel-1A, SA, Sentinel-1B, SB, SMAP, SP, UAVSAR, UA.
class
ASFSearchForm
(
forms
.
Form
):
polygon
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
"form-control"
}))
...
...
catalog/migrations/0011_auto_20190206_
1555
.py
→
catalog/migrations/0011_auto_20190206_
2146
.py
View file @
96f8a1cd
# Generated by Django 2.0.5 on 2019-02-06 15:55
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-02-06 21:46
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.db
import
migrations
,
models
...
...
@@ -17,6 +19,7 @@ class Migration(migrations.Migration):
name
=
'Purchase'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'aggreg_date'
,
models
.
DateTimeField
(
auto_now
=
True
)),
(
'productList'
,
models
.
TextField
(
verbose_name
=
'JSON Product List'
)),
(
'purchased'
,
models
.
BooleanField
(
default
=
False
)),
(
'price'
,
models
.
FloatField
(
default
=
0.0
)),
...
...
@@ -26,9 +29,12 @@ class Migration(migrations.Migration):
name
=
'Search'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'area'
,
models
.
TextField
(
null
=
True
)),
(
'aggreg_date'
,
models
.
DateTimeField
(
auto_now
=
True
)),
(
'startDate'
,
models
.
DateTimeField
(
verbose_name
=
'Start Date'
)),
(
'endDate'
,
models
.
DateTimeField
(
verbose_name
=
'End Date'
)),
(
'clouds'
,
models
.
IntegerField
(
default
=
4
)),
(
'user'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
RenameField
(
...
...
@@ -46,15 +52,35 @@ class Migration(migrations.Migration):
name
=
'productLevel'
,
field
=
models
.
CharField
(
default
=
''
,
max_length
=
8
),
),
migrations
.
A
dd
Field
(
model_name
=
'
search
'
,
name
=
'
process
'
,
field
=
models
.
ForeignKey
(
default
=
''
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'catalog.Process
'
),
migrations
.
A
lter
Field
(
model_name
=
'
polygon
'
,
name
=
'
name
'
,
field
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'Polygon Name
'
),
),
migrations
.
AddField
(
model_name
=
'search'
,
name
=
'user'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
),
migrations
.
AlterField
(
model_name
=
'polygon'
,
name
=
'source'
,
field
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
verbose_name
=
'Source'
),
),
migrations
.
AlterField
(
model_name
=
'product_l1c'
,
name
=
'file_path'
,
field
=
models
.
CharField
(
max_length
=
150
),
),
migrations
.
AlterField
(
model_name
=
'product_l1c'
,
name
=
'identifier'
,
field
=
models
.
CharField
(
max_length
=
100
),
),
migrations
.
AlterField
(
model_name
=
'product_l2a'
,
name
=
'file_path'
,
field
=
models
.
CharField
(
max_length
=
150
),
),
migrations
.
AlterField
(
model_name
=
'product_l2a'
,
name
=
'identifier'
,
field
=
models
.
CharField
(
max_length
=
100
),
),
migrations
.
AddField
(
model_name
=
'purchase'
,
...
...
catalog/migrations/0012_auto_20190206_1843.py
deleted
100644 → 0
View file @
fc0afb58
# Generated by Django 2.1.5 on 2019-02-06 18:43
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalog'
,
'0011_auto_20190206_1555'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'polygon'
,
name
=
'name'
,
field
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'Polygon Name'
),
),
migrations
.
AlterField
(
model_name
=
'polygon'
,
name
=
'source'
,
field
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
verbose_name
=
'Source'
),
),
migrations
.
AlterField
(
model_name
=
'product_l1c'
,
name
=
'file_path'
,
field
=
models
.
CharField
(
max_length
=
150
),
),
migrations
.
AlterField
(
model_name
=
'product_l1c'
,
name
=
'identifier'
,
field
=
models
.
CharField
(
max_length
=
100
),
),
migrations
.
AlterField
(
model_name
=
'product_l2a'
,
name
=
'file_path'
,
field
=
models
.
CharField
(
max_length
=
150
),
),
migrations
.
AlterField
(
model_name
=
'product_l2a'
,
name
=
'identifier'
,
field
=
models
.
CharField
(
max_length
=
100
),
),
]
catalog/migrations/0012_search_process.py
0 → 100644
View file @
96f8a1cd
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-02-07 18:32
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalog'
,
'0011_auto_20190206_2146'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'search'
,
name
=
'process'
,
field
=
models
.
ForeignKey
(
default
=
''
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'catalog.Process'
),
),
]
catalog/models.py
View file @
96f8a1cd
...
...
@@ -47,7 +47,6 @@ class CartProduct(models.Model):
info
=
models
.
TextField
(
null
=
True
)
purchased
=
models
.
NullBooleanField
()
# -------------------------------------------------------------------------------------------
class
Process
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
...
...
@@ -61,7 +60,7 @@ class Search(models.Model):
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
# date of product aggregation
startDate
=
models
.
DateTimeField
(
verbose_name
=
'Start Date'
)
endDate
=
models
.
DateTimeField
(
verbose_name
=
'End Date'
)
#process = models.ForeignKey(Process, on_delete=models.CASCADE, default='')
process
=
models
.
ForeignKey
(
Process
,
on_delete
=
models
.
CASCADE
,
default
=
''
)
#Desbloqueo cambio de Sergio
clouds
=
models
.
IntegerField
(
default
=
4
)
...
...
catalog/static/catalog/css/body.css
View file @
96f8a1cd
...
...
@@ -337,7 +337,7 @@ div #product-list-globe {
div
#product-list-cart-items
{
max-height
:
700px
;
max-width
:
207px
;
max-width
:
105%
;
overflow
:
auto
;
}
...
...
@@ -351,7 +351,7 @@ ul #product-list-cart-items li:hover div.bg-geo {
div
.product_list_category
{
max-height
:
700px
;
max-width
:
207px
;
max-width
:
105%
;
overflow
:
auto
;
}
...
...
@@ -423,3 +423,14 @@ div .sidebar-input input[type="text"] {
border
:
1px
solid
transparent
;
height
:
35px
;
}
.control-sidebar
{
right
:
-250px
;
width
:
250px
;
}
.control-sidebar-bg
{
right
:
-250px
;
width
:
250px
;
}
.control-sidebar-open
{
right
:
0px
!important
;
}
\ No newline at end of file
catalog/static/catalog/js/dataRetrieval.js
View file @
96f8a1cd
...
...
@@ -102,6 +102,22 @@ function updateCart(){
});
};
function
deleteProductCar
(
element
){
let
id
=
element
.
parentElement
.
querySelector
(
'span'
).
id
;
element
.
parentElement
.
parentElement
.
classList
.
remove
(
'treeview'
);
$
.
ajax
({
type
:
'POST'
,
url
:
del_prod_cartDB_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'id'
:
id
},
dataType
:
'json'
,
success
:
function
(
data
)
{
element
.
parentElement
.
parentElement
.
remove
();
}
});
}
function
drawPolygon
(
element
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
...
...
@@ -211,7 +227,8 @@ function createProductContainer(products) {
products
.
forEach
(
function
(
list
){
var
temp_1
=
document
.
querySelector
(
'#product_cart_1'
);
let
name
=
list
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
name
;
temp_1
.
content
.
querySelector
(
'span'
).
id
=
list
.
id
;
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
list
.
aggreg_date
;
temp_1
.
content
.
querySelector
(
'ul .control-sidebar-menu'
).
id
=
"L-"
+
name
;
var
clone_1
=
document
.
importNode
(
temp_1
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart'
).
appendChild
(
clone_1
);
...
...
catalog/templates/base_top.html
View file @
96f8a1cd
...
...
@@ -162,7 +162,7 @@
</div>
</div>
<!-- this ul element is filled with data -->
<ul
id=
"product-list-cart"
class=
"sidebar-menu"
data-widget=
"tree"
></ul>
<ul
id=
"product-list-cart"
class=
"
control-
sidebar-menu"
data-widget=
"tree"
></ul>
</div>
<!-- /.tab-pane -->
</div>
...
...
catalog/templates/map.html
View file @
96f8a1cd
...
...
@@ -359,5 +359,6 @@
var
prod_cart_url
=
"{% url 'cart-rqst' %}"
;
// url for requesting product saving in cart
var
prod_from_cartDB_url
=
"{% url 'from-cart-rqst' %}"
;
// url for requesting product from cart table in DB
var
purch_prod_url
=
"{% url 'purch-prod-rqst' %}"
;
var
del_prod_cartDB_url
=
"{% url 'del-cart-rqst' %}"
;
</script>
{% endblock %}
catalog/templates/templates.html
View file @
96f8a1cd
...
...
@@ -74,6 +74,7 @@
<a
href=
"#"
>
<i
class=
"fa fa-cubes"
></i>
<span></span>
<i
class=
"glyphicon glyphicon-remove"
style=
"padding-left: 15px"
onclick=
"deleteProductCar(this);"
></i>
<span
class=
"pull-right-container"
>
<span
class=
"label label-primary pull-right"
></span>
</span>
...
...
catalog/urls.py
View file @
96f8a1cd
...
...
@@ -11,6 +11,7 @@ urlpatterns = [
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
url
(
r'^delcartrqst/$'
,
views
.
delFromCart
,
name
=
'del-cart-rqst'
),
url
(
r'^purchcartrqst/$'
,
views
.
purchaseProduct
,
name
=
'purch-prod-rqst'
),
url
(
r'^cart/$'
,
views
.
showCart
,
name
=
'show-cart'
),
]
catalog/views.py
View file @
96f8a1cd
...
...
@@ -2,7 +2,7 @@
from
__future__
import
unicode_literals
from
django.shortcuts
import
render
from
catalog.forms
import
ASFSearchForm
from
catalog.models
import
Polygon
,
CartProduct
,
Product_l1c
,
Search
,
Purchase
from
catalog.models
import
Polygon
,
CartProduct
,
Product_l1c
,
Search
,
Purchase
,
Process
from
django.http
import
HttpResponse
,
JsonResponse
,
HttpResponseRedirect
from
django.urls
import
reverse
from
django.views.generic.base
import
View
...
...
@@ -15,7 +15,7 @@ import requests, json, unicodedata, sys, base64
import
os
import
sys
sys
.
path
.
append
(
'
../GeoSentinel/
'
)
sys
.
path
.
append
(
'
/home/luis/django-apps/Geosentinel
'
)
from
geosentinel
import
APISentinel
,
polygonToBox
sentinel
=
APISentinel
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
...
...
@@ -111,12 +111,17 @@ def productList(request):
'img'
:
img_preview
})
#Se tiene que pasar a Search el objeto completo correspondiente al process
index
=
Process
.
objects
.
filter
(
platform_id
=
process
)
proceso
=
index
[
0
]
if
(
len
(
catalog
)
!=
0
):
listSearch
=
Search
(
user
=
user
,
startDate
=
init_date
,
endDate
=
end_date
,
#process = process,
process
=
proceso
,
#Aquí pasar el objeto completo de Process Desbloqueo cambio de Sergio
clouds
=
clouds
,
area
=
area
)
...
...
@@ -208,7 +213,7 @@ def getFromCart(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
)
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_date'
,
'id'
)
.
filter
(
user
=
user
,
purchased
=
0
)
for
products
in
product_list
:
product
=
json
.
loads
(
products
[
'productList'
])
...
...
@@ -216,10 +221,17 @@ def getFromCart(request):
'purchased'
:
products
[
'purchased'
],
'price'
:
products
[
'price'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'id'
:
products
[
'id'
],
'catalog'
:
product
})
return
JsonResponse
({
'product_list'
:
prod_list
})
#-------------------------------------------------------------------------------
def
delFromCart
(
request
):
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
product_list
=
Purchase
.
objects
.
filter
(
user
=
user
,
id
=
request
.
POST
[
'id'
])
.
delete
()
return
HttpResponse
(
status
=
204
)
##-------------------------------------------------------------------------------
#def L2ASCL_data(request):
# with open("/home/mario/NAS_MarioCh/mario_repsat_test/T15QZD_sclData.json") as f:
...
...
@@ -263,54 +275,76 @@ def purchaseProduct(request):
For now to purchase a product consists in verifying whether L1C products in cart already exist in DB.
"""
# ------------- crear archivo findProducts.json
print
(
"Comprar productos!!!!"
)
print
(
request
)
print
(
"start date:"
)
print
(
request
.
POST
[
'wkt'
])
print
(
request
.
POST
[
'startDate'
])
print
(
request
.
POST
[
'endDate'
])
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/"
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
prod_list
=
[]
product_list
=
Search
.
objects
.
values
(
'user'
,
'area'
,
'startDate'
,
'endDate'
,
'clouds'
)
.
filter
(
user
=
user
,
purchased
=
0
)
#obtiene los datos para el json
data
=
{}
data
[
'wkt'
]
=
request
.
POST
[
'wkt'
]
data
[
'platform'
]
=
'Sentinel-2'
data
[
'productLevel'
]
=
'L2A'
data
[
'startDate'
]
=
fecha_inicio
.
replace
(
"-"
,
""
)
#quita los guiones de la fecha
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['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
#~ data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
data
[
'productsDir'
]
=
products_dir
data
[
'linksDir'
]
=
linksDir
data
[
'username'
]
=
'mario-chirinos'
data
[
'password'
]
=
'r4nc0r4u'
#json_data = json.dumps(data, indent=4,sort_keys=True)
#formatea el json
json_data
=
json
.
dumps
(
data
,
indent
=
4
)
print
(
json_data
)
#escribe el json en el archivo
fidProductsFile
=
open
(
userdir
+
"/findProducts.json"
,
"w"
)
fidProductsFile
.
write
(
json_data
)
fidProductsFile
.
close
()
for
products
in
product_list
:
print
(
products
)
#~ product = json.loads(products['productList'])
#~ prod_list.append({
#~ 'purchased': products['purchased'],
#~ 'price' : products['price'],
#~ 'aggreg_date' : products['aggreg_date'],
#~ 'catalog': product
#~ })
#~ return JsonResponse({'product_list': prod_list})
#~ print("Comprar productos!!!!")
#~ print(request)
#~ print("start date:")
#~ print(request.POST['wkt'])
#~ print(request.POST['startDate'])
#~ print(request.POST['endDate'])
#~ 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
#~ data = {}
#~ data['wkt'] = request.POST['wkt']
#~ data['platform'] = 'Sentinel-2'
#~ data['productLevel'] = 'L2A'
#~ data['startDate'] = fecha_inicio.replace("-", "") #quita los guiones de la fecha
#~ 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['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
#~ # data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
#~ data['productsDir'] = products_dir
#~ data['linksDir'] = linksDir
#~ data['username'] = 'mario-chirinos'
#~ data['password'] = 'r4nc0r4u'
#~ #json_data = json.dumps(data, indent=4,sort_keys=True)
#~ #formatea el json
#~ json_data = json.dumps(data, indent=4)
#~ print(json_data)
#~ #escribe el json en el archivo
#~ fidProductsFile = open(userdir+"/findProducts.json", "w")
#~ fidProductsFile.write(json_data)
#~ fidProductsFile.close()
#-------------------------------------------------
...
...
@@ -398,6 +432,85 @@ def purchaseProduct(request):
#-------------------------------------------------------------------------------
def
showCart
(
request
):
#---------------test process----------------------
print
(
"showcart!!!"
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
query
=
[]
query
=
Purchase
.
objects
.
values
(
'search__area'
,
'user'
,
'user__username'
,
'user__email'
,
'search_id'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
)
.
filter
(
user
=
user
,
purchased
=
0
)
for
values
in
query
:
print
(
values
[
'user__username'
])
print
(
values
[
'user__email'
])
print
(
values
[
'search_id'
])
print
(
str
(
values
[
'search__startDate'
]
.
date
())
.
replace
(
"-"
,
""
))
print
(
str
(
values
[
'search__endDate'
]
.
date
())
.
replace
(
"-"
,
""
))
print
(
values
[
'search__clouds'
])
print
(
values
[
'search__area'
])
username
=
values
[
'user__username'
]
useremail
=
values
[
'user__email'
]
userdir
=
NAS_PATH
+
"repsat_test_dev/"
+
useremail
##crea el directorio del usuario
if
not
os
.
path
.
exists
(
userdir
):
os
.
makedirs
(
userdir
)
search_dir
=
userdir
+
"/"
+
str
(
values
[
'search_id'
])
if
not
os
.
path
.
exists
(
search_dir
):
os
.
makedirs
(
search_dir
)
products_dir
=
NAS_PATH
+
"sentinelImages/L2A/"
linksDir
=
search_dir
+
"/L2A/"
#obtiene los datos para el json
data
=
{}
data
[
'wkt'
]
=
values
[
'search__area'
]
data
[
'platform'
]
=
'Sentinel-2'
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'
#json_data = json.dumps(data, indent=4,sort_keys=True)
#formatea el json
json_data
=
json
.
dumps
(
data
,
indent
=
4
)
print
(
json_data
)
#escribe el json en el archivo
fidProductsFile
=
open
(
search_dir
+
"/findProducts.json"
,
"w"
)
fidProductsFile
.
write
(
json_data
)
fidProductsFile
.
close
()
#~ user = User.objects.get(id=request.user.id)
#~ prod_list = []
#~ product_list = Search.objects.values('user', 'area', 'startDate', 'endDate','clouds').filter(user=user)
#~ data = {}
#~ for products in product_list:
#~ print(products)
#~ product = json.loads(products['productList'])
#~ prod_list.append({
#~ 'purchased': products['purchased'],
#~ 'price' : products['price'],
#~ 'aggreg_date' : products['aggreg_date'],
#~ 'catalog': product
#~ })
#~ return JsonResponse({'product_list': prod_list})
#-------------------------------------
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
)
...
...
db.sqlite3
View file @
96f8a1cd
No preview for this file type
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