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
e72f36a7
Commit
e72f36a7
authored
Feb 06, 2019
by
José Luis Uc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev
parents
46c03e0a
6ddcc845
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
77 deletions
+140
-77
settings.py
GeoInt_SIDT/settings.py
+1
-1
0012_auto_20190206_1843.py
catalog/migrations/0012_auto_20190206_1843.py
+43
-0
models.py
catalog/models.py
+43
-36
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+21
-16
views.py
catalog/views.py
+32
-24
db.sqlite3
db.sqlite3
+0
-0
No files found.
GeoInt_SIDT/settings.py
View file @
e72f36a7
catalog/migrations/0012_auto_20190206_1843.py
0 → 100644
View file @
e72f36a7
# 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/models.py
View file @
e72f36a7
...
@@ -13,10 +13,10 @@ class Platform(models.Model):
...
@@ -13,10 +13,10 @@ class Platform(models.Model):
class
Polygon
(
models
.
Model
):
class
Polygon
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Polygon Name"
,
max_length
=
5
0
)
name
=
models
.
CharField
(
verbose_name
=
"Polygon Name"
,
max_length
=
10
0
)
json_info
=
models
.
TextField
(
verbose_name
=
"JSON Info"
)
json_info
=
models
.
TextField
(
verbose_name
=
"JSON Info"
)
description
=
models
.
TextField
(
verbose_name
=
"Description"
,
null
=
True
)
description
=
models
.
TextField
(
verbose_name
=
"Description"
,
null
=
True
)
source
=
models
.
CharField
(
verbose_name
=
"Source"
,
max_length
=
5
0
,
null
=
True
)
source
=
models
.
CharField
(
verbose_name
=
"Source"
,
max_length
=
10
0
,
null
=
True
)
CVE_ENT
=
models
.
CharField
(
verbose_name
=
"State Key"
,
max_length
=
10
,
null
=
True
)
CVE_ENT
=
models
.
CharField
(
verbose_name
=
"State Key"
,
max_length
=
10
,
null
=
True
)
CVE_MUN
=
models
.
CharField
(
verbose_name
=
"City Key"
,
max_length
=
10
,
null
=
True
)
CVE_MUN
=
models
.
CharField
(
verbose_name
=
"City Key"
,
max_length
=
10
,
null
=
True
)
CVE_LOC
=
models
.
CharField
(
verbose_name
=
"Location Key"
,
max_length
=
10
,
null
=
True
)
CVE_LOC
=
models
.
CharField
(
verbose_name
=
"Location Key"
,
max_length
=
10
,
null
=
True
)
...
@@ -29,15 +29,15 @@ class Polygon(models.Model):
...
@@ -29,15 +29,15 @@ class Polygon(models.Model):
class
Product_l1c
(
models
.
Model
):
class
Product_l1c
(
models
.
Model
):
uuid
=
models
.
CharField
(
max_length
=
50
)
uuid
=
models
.
CharField
(
max_length
=
50
)
identifier
=
models
.
CharField
(
max_length
=
5
0
)
identifier
=
models
.
CharField
(
max_length
=
10
0
)
file_path
=
models
.
CharField
(
max_length
=
50
)
file_path
=
models
.
CharField
(
max_length
=
1
50
)
json
=
models
.
TextField
(
null
=
True
)
json
=
models
.
TextField
(
null
=
True
)
class
Product_l2a
(
models
.
Model
):
class
Product_l2a
(
models
.
Model
):
prod_l1c
=
models
.
ForeignKey
(
Product_l1c
,
on_delete
=
models
.
CASCADE
)
prod_l1c
=
models
.
ForeignKey
(
Product_l1c
,
on_delete
=
models
.
CASCADE
)
identifier
=
models
.
CharField
(
max_length
=
5
0
)
identifier
=
models
.
CharField
(
max_length
=
10
0
)
file_path
=
models
.
CharField
(
max_length
=
50
)
file_path
=
models
.
CharField
(
max_length
=
1
50
)
class
CartProduct
(
models
.
Model
):
class
CartProduct
(
models
.
Model
):
...
@@ -47,22 +47,29 @@ class CartProduct(models.Model):
...
@@ -47,22 +47,29 @@ class CartProduct(models.Model):
info
=
models
.
TextField
(
null
=
True
)
info
=
models
.
TextField
(
null
=
True
)
purchased
=
models
.
NullBooleanField
()
purchased
=
models
.
NullBooleanField
()
#-------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
class
Process
(
models
.
Model
):
class
Process
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
platform
=
models
.
ForeignKey
(
Platform
,
on_delete
=
models
.
CASCADE
,
default
=
''
)
platform
=
models
.
ForeignKey
(
Platform
,
on_delete
=
models
.
CASCADE
,
default
=
''
)
productLevel
=
models
.
CharField
(
max_length
=
8
,
default
=
''
)
productLevel
=
models
.
CharField
(
max_length
=
8
,
default
=
''
)
class
Search
(
models
.
Model
):
class
Search
(
models
.
Model
):
area
=
models
.
TextField
(
null
=
True
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
# date of product aggregation
startDate
=
models
.
DateTimeField
(
verbose_name
=
'Start Date'
)
startDate
=
models
.
DateTimeField
(
verbose_name
=
'Start Date'
)
endDate
=
models
.
DateTimeField
(
verbose_name
=
'End 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='')
clouds
=
models
.
IntegerField
(
default
=
4
)
clouds
=
models
.
IntegerField
(
default
=
4
)
class
Purchase
(
models
.
Model
):
class
Purchase
(
models
.
Model
):
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
# date of product aggregation
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
search
=
models
.
ForeignKey
(
Search
,
on_delete
=
models
.
CASCADE
)
search
=
models
.
ForeignKey
(
Search
,
on_delete
=
models
.
CASCADE
)
productList
=
models
.
TextField
(
verbose_name
=
"JSON Product List"
)
productList
=
models
.
TextField
(
verbose_name
=
"JSON Product List"
)
purchased
=
models
.
BooleanField
(
default
=
False
)
purchased
=
models
.
BooleanField
(
default
=
False
)
price
=
models
.
FloatField
(
default
=
0.0
)
price
=
models
.
FloatField
(
default
=
0.0
)
catalog/static/catalog/js/dataRetrieval.js
View file @
e72f36a7
...
@@ -342,7 +342,10 @@ $(document).ready(function () {
...
@@ -342,7 +342,10 @@ $(document).ready(function () {
var
clone
=
document
.
importNode
(
temp
.
content
,
true
);
var
clone
=
document
.
importNode
(
temp
.
content
,
true
);
//document.querySelector('#product-list-globe').appendChild(clone);
//document.querySelector('#product-list-globe').appendChild(clone);
// console.log('#L-' + data.product.tileid);
setTimeout
(()
=>
{
document
.
querySelector
(
'#L-'
+
data
.
product
.
tileid
).
appendChild
(
clone
);
document
.
querySelector
(
'#L-'
+
data
.
product
.
tileid
).
appendChild
(
clone
);
},
100
);
}
}
});
});
...
@@ -432,7 +435,8 @@ $(document).ready(function () {
...
@@ -432,7 +435,8 @@ $(document).ready(function () {
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
productsToObtain
=
[];
productsToObtain
=
[];
data
.
product_list
.
forEach
(
function
(
product
)
{
data
.
product_list
.
forEach
(
function
(
products
)
{
products
.
catalog
.
forEach
(
function
(
product
){
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
// filling template
// filling template
...
@@ -448,6 +452,7 @@ $(document).ready(function () {
...
@@ -448,6 +452,7 @@ $(document).ready(function () {
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
});
});
});
}
}
});
});
}
}
...
...
catalog/views.py
View file @
e72f36a7
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
catalog.forms
import
ASFSearchForm
from
catalog.forms
import
ASFSearchForm
from
catalog.models
import
Polygon
,
CartProduct
,
Product_l1c
from
catalog.models
import
Polygon
,
CartProduct
,
Product_l1c
,
Search
,
Purchase
from
django.http
import
HttpResponse
,
JsonResponse
,
HttpResponseRedirect
from
django.http
import
HttpResponse
,
JsonResponse
,
HttpResponseRedirect
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.views.generic.base
import
View
from
django.views.generic.base
import
View
...
@@ -62,10 +62,12 @@ def productList(request):
...
@@ -62,10 +62,12 @@ def productList(request):
req
=
dict
(
request
.
POST
)
req
=
dict
(
request
.
POST
)
req
.
pop
(
'csrfmiddlewaretoken'
,
None
)
req
.
pop
(
'csrfmiddlewaretoken'
,
None
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
process
=
req
[
'platform'
][
0
]
process
=
req
[
'platform'
][
0
]
area
=
req
[
'polygon'
][
0
]
area
=
req
[
'polygon'
][
0
]
init_date
=
req
[
'start'
][
0
][:
10
]
init_date
=
req
[
'start'
][
0
][:
10
]
end_date
=
req
[
'end'
][
0
][:
10
]
end_date
=
req
[
'end'
][
0
][:
10
]
clouds
=
req
[
'cloudPercentage'
][
0
]
cloud_percentage
=
"[0 TO "
+
req
[
'cloudPercentage'
][
0
]
+
"]"
cloud_percentage
=
"[0 TO "
+
req
[
'cloudPercentage'
][
0
]
+
"]"
...
@@ -107,6 +109,17 @@ def productList(request):
...
@@ -107,6 +109,17 @@ def productList(request):
'img'
:
img_preview
'img'
:
img_preview
})
})
if
(
len
(
catalog
)
!=
0
):
listSearch
=
Search
(
user
=
user
,
startDate
=
init_date
,
endDate
=
end_date
,
#process = process,
clouds
=
clouds
,
area
=
area
)
listSearch
.
save
()
return
JsonResponse
({
'catalog'
:
catalog
});
return
JsonResponse
({
'catalog'
:
catalog
});
# return HttpResponse(status=204)
# return HttpResponse(status=204)
...
@@ -171,23 +184,18 @@ def saveInCart(request):
...
@@ -171,23 +184,18 @@ def saveInCart(request):
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
product_list
=
json
.
loads
(
request
.
POST
[
'cart_product_list'
])
product_list
=
json
.
loads
(
request
.
POST
[
'cart_product_list'
])
search
=
Search
.
objects
.
filter
(
user
=
user
)
.
last
()
for
product
in
product_list
:
if
(
len
(
product_list
)
!=
0
):
p_uuid
=
product
[
'uuid'
]
cartProd
=
Purchase
(
p_info
=
product
[
'info'
]
PRODUCT_EXISTS
=
CartProduct
.
objects
.
filter
(
uuid
=
p_uuid
,
user
=
user
)
.
exists
()
if
not
PRODUCT_EXISTS
:
cartProd
=
CartProduct
(
user
=
user
,
user
=
user
,
uuid
=
p_uuid
,
search
=
search
,
info
=
json
.
dumps
(
p_info
,
indent
=
3
,
sort_keys
=
True
,
ensure_ascii
=
True
),
productList
=
json
.
dumps
(
product_list
,
indent
=
3
,
sort_keys
=
True
,
ensure_ascii
=
True
),
purchased
=
False
purchased
=
False
,
price
=
5.0
)
)
cartProd
.
save
()
cartProd
.
save
()
return
HttpResponse
(
status
=
204
)
return
HttpResponse
(
status
=
204
)
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
...
@@ -197,16 +205,16 @@ def getFromCart(request):
...
@@ -197,16 +205,16 @@ def getFromCart(request):
"""
"""
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
prod_uuid_list
=
request
.
POST
[
'product_uuid_list'
]
.
split
(
","
)
prod_list
=
[]
prod_list
=
[]
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
)
.
filter
(
user
=
user
,
purchased
=
0
)
for
prod
_uuid
in
prod_uuid
_list
:
for
prod
ucts
in
product
_list
:
product
=
CartProduct
.
objects
.
filter
(
uuid
=
prod_uuid
,
user
=
user
)
.
first
(
)
product
=
json
.
loads
(
products
[
'productList'
]
)
prod_list
.
append
({
prod_list
.
append
({
'uuid'
:
product
.
uuid
,
'purchased'
:
products
[
'purchased'
],
'info'
:
json
.
loads
(
product
.
info
)
'price'
:
products
[
'price'
],
'catalog'
:
product
})
})
return
JsonResponse
({
'product_list'
:
prod_list
})
return
JsonResponse
({
'product_list'
:
prod_list
})
##-------------------------------------------------------------------------------
##-------------------------------------------------------------------------------
...
...
db.sqlite3
View file @
e72f36a7
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