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
19cbf5c2
Commit
19cbf5c2
authored
Feb 06, 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
937b4287
f0537364
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
413 additions
and
63 deletions
+413
-63
body.css
catalog/static/catalog/css/body.css
+6
-1
map.css
catalog/static/catalog/css/map.css
+2
-1
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+50
-50
base_top.html
catalog/templates/base_top.html
+17
-3
map.html
catalog/templates/map.html
+1
-0
show_cart.html
catalog/templates/show_cart.html
+285
-0
templates.html
catalog/templates/templates.html
+2
-2
urls.py
catalog/urls.py
+1
-0
views.py
catalog/views.py
+49
-6
No files found.
catalog/static/catalog/css/body.css
View file @
19cbf5c2
...
@@ -331,7 +331,7 @@ div .menu-info h4 {
...
@@ -331,7 +331,7 @@ div .menu-info h4 {
/*}*/
/*}*/
div
#product-list-globe
{
div
#product-list-globe
{
max-height
:
773
px
;
max-height
:
820
px
;
overflow
:
auto
;
overflow
:
auto
;
}
}
...
@@ -363,6 +363,11 @@ ul.product_list_category li:hover div.bg-geo {
...
@@ -363,6 +363,11 @@ ul.product_list_category li:hover div.bg-geo {
display
:
block
;
display
:
block
;
}
}
div
#product-list-cart
{
max-height
:
820px
;
overflow
:
auto
;
}
/*div #product-list-cart-items {
/*div #product-list-cart-items {
max-height: 167px;
max-height: 167px;
overflow: auto;
overflow: auto;
...
...
catalog/static/catalog/css/map.css
View file @
19cbf5c2
...
@@ -17,7 +17,8 @@ html, body
...
@@ -17,7 +17,8 @@ html, body
position
:
absolute
;
position
:
absolute
;
bottom
:
0
;
bottom
:
0
;
border
:
0px
solid
blue
;
border
:
0px
solid
blue
;
z-index
:
99999
;
/* z-index: 99999; */
z-index
:
6
!important
;
width
:
100%
;
width
:
100%
;
height
:
32px
;
height
:
32px
;
vertical-align
:
middle
;
vertical-align
:
middle
;
...
...
catalog/static/catalog/js/dataRetrieval.js
View file @
19cbf5c2
...
@@ -66,6 +66,42 @@ var makeRequest = function (value) {
...
@@ -66,6 +66,42 @@ var makeRequest = function (value) {
});
});
};
};
function
updateCart
(){
$
(
"#product-list-cart"
).
empty
();
$
.
ajax
({
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
},
dataType
:
'json'
,
success
:
function
(
data
)
{
productsToObtain
=
[];
createProductContainer
(
data
.
product_list
);
data
.
product_list
.
forEach
(
function
(
products
)
{
let
id
=
"L-"
+
products
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
products
.
catalog
.
forEach
(
function
(
product
)
{
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
// filling template
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
//document.querySelector('#product-list-cart-items').appendChild(clone_2);
document
.
querySelector
(
'#'
+
id
).
appendChild
(
clone_2
);
});
});
}
});
};
function
drawPolygon
(
element
)
{
function
drawPolygon
(
element
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
...
@@ -171,14 +207,15 @@ function drawApiResponse(element) {
...
@@ -171,14 +207,15 @@ function drawApiResponse(element) {
}
}
function
createProductContainer
()
{
function
createProductContainer
(
products
)
{
products
.
forEach
(
function
(
list
){
var
temp_1
=
document
.
querySelector
(
'#product_cart_1'
);
var
temp_1
=
document
.
querySelector
(
'#product_cart_1'
);
let
name
=
list
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
// filling template
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
name
;
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
"Product"
;
temp_1
.
content
.
querySelector
(
'ul .control-sidebar-menu'
).
id
=
"L-"
+
name
;
var
clone_1
=
document
.
importNode
(
temp_1
.
content
,
true
);
var
clone_1
=
document
.
importNode
(
temp_1
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart'
).
appendChild
(
clone_1
);
document
.
querySelector
(
'#product-list-cart'
).
appendChild
(
clone_1
);
})
}
}
let
productCategory
=
new
Map
();
let
productCategory
=
new
Map
();
...
@@ -416,45 +453,7 @@ $(document).ready(function () {
...
@@ -416,45 +453,7 @@ $(document).ready(function () {
success
:
function
()
{
success
:
function
()
{
cartProductList
=
[];
cartProductList
=
[];
productUUIDListCart
.
push
.
apply
(
productUUIDListCart
,
productsToObtain
);
productUUIDListCart
.
push
.
apply
(
productUUIDListCart
,
productsToObtain
);
updateCart
();
if
(
!
IS_PRODUCT_CONTAINER
)
{
// building product container
createProductContainer
();
IS_PRODUCT_CONTAINER
=
true
;
// this flag is set to false when products are purchased
}
// request to DB for showing the products in cart
// variable prod_from_cartDB_url in map.html
$
.
ajax
({
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'product_uuid_list'
:
productsToObtain
.
toString
()
},
dataType
:
'json'
,
success
:
function
(
data
)
{
productsToObtain
=
[];
data
.
product_list
.
forEach
(
function
(
products
)
{
products
.
catalog
.
forEach
(
function
(
product
){
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
// filling template
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
});
});
}
});
}
}
});
});
}
else
{
}
else
{
...
@@ -494,6 +493,7 @@ $(document).ready(function () {
...
@@ -494,6 +493,7 @@ $(document).ready(function () {
'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'
});
});
...
...
catalog/templates/base_top.html
View file @
19cbf5c2
...
@@ -104,7 +104,7 @@
...
@@ -104,7 +104,7 @@
<!-- Create the tabs -->
<!-- Create the tabs -->
<ul
class=
"nav nav-tabs nav-justified control-sidebar-tabs"
>
<ul
class=
"nav nav-tabs nav-justified control-sidebar-tabs"
>
<li
id=
"globe"
><a
href=
"#control-sidebar-home-tab"
data-toggle=
"tab"
><i
class=
"fa fa-globe"
></i></a></li>
<li
id=
"globe"
><a
href=
"#control-sidebar-home-tab"
data-toggle=
"tab"
><i
class=
"fa fa-globe"
></i></a></li>
<li
id=
"cart"
><a
href=
"#control-sidebar-settings-tab"
data-toggle=
"tab"
><i
class=
"fa fa-shopping-cart"
></i></a>
<li
id=
"cart"
><a
href=
"#control-sidebar-settings-tab"
onclick=
"updateCart()"
data-toggle=
"tab"
><i
class=
"fa fa-shopping-cart"
></i></a>
</li>
</li>
</ul>
</ul>
<!-- Tab panes -->
<!-- Tab panes -->
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
<!-- /.tab-pane -->
<!-- /.tab-pane -->
<!-- Settings tab content -->
<!-- Settings tab content -->
<div
class=
"tab-pane"
id=
"control-sidebar-settings-tab"
>
<div
class=
"tab-pane"
id=
"control-sidebar-settings-tab"
>
<form
id=
'purchased-product-form'
role=
"form"
method=
"post"
>
{% comment %}
<form
id=
'purchased-product-form'
role=
"form"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"sidebar-title"
>
<div
class=
"sidebar-title"
>
...
@@ -148,7 +148,21 @@
...
@@ -148,7 +148,21 @@
</div>
</div>
<!-- this ul element is filled with data -->
<!-- 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=
"sidebar-menu"
data-widget=
"tree"
></ul>
</form>
</form>
{% endcomment %}
<div
class=
"container"
>
<div
class=
"sidebar-title"
>
<h3><b>
My cart
</b></h3>
</div>
<div
class=
"sidebar-button"
>
{% comment %}
<button
type=
"submit"
name=
"search"
id=
"purchase"
class=
"btn btn-primary"
>
Purchase
</button>
{% endcomment %}
{% comment %}
<a
href=
"cart"
id=
"purchase"
class=
"btn btn-primary"
>
Purchase
</a>
{% endcomment %}
<button
onclick=
"location.href='cart'"
id=
"purchase"
class=
"btn btn-primary"
>
Purchase
</button>
</div>
</div>
<!-- this ul element is filled with data -->
<ul
id=
"product-list-cart"
class=
"sidebar-menu"
data-widget=
"tree"
></ul>
</div>
</div>
<!-- /.tab-pane -->
<!-- /.tab-pane -->
</div>
</div>
...
...
catalog/templates/map.html
View file @
19cbf5c2
...
@@ -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=
"#"
>
...
...
catalog/templates/show_cart.html
0 → 100644
View file @
19cbf5c2
{% extends "base_top.html" %}
{% 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"
>
<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>
{% endblock %}
{% block messages %}
<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"
>
<li
class=
"header"
>
You have 4 messages
</li>
<li>
<!-- inner menu: contains the actual data -->
<ul
class=
"menu"
>
<li>
<!-- start message -->
<a
href=
"#"
>
<div
class=
"pull-left"
>
<img
src=
"dist/img/user2-160x160.jpg"
class=
"img-circle"
alt=
"User Image"
>
</div>
<h4>
Support Team
<small><i
class=
"fa fa-clock-o"
></i>
5 mins
</small>
</h4>
<p>
Why not buy a new awesome theme?
</p>
</a>
</li>
<!-- end message -->
<li>
<a
href=
"#"
>
<div
class=
"pull-left"
>
<img
src=
"dist/img/user3-128x128.jpg"
class=
"img-circle"
alt=
"User Image"
>
</div>
<h4>
AdminLTE Design Team
<small><i
class=
"fa fa-clock-o"
></i>
2 hours
</small>
</h4>
<p>
Why not buy a new awesome theme?
</p>
</a>
</li>
</ul>
</li>
<li
class=
"footer"
><a
href=
"#"
>
See All Messages
</a></li>
</ul>
{% endblock %}
{% block notifications %}
<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"
>
<li
class=
"header"
>
You have 10 notifications
</li>
<li>
<!-- inner menu: contains the actual data -->
<ul
class=
"menu"
>
<li>
<a
href=
"#"
>
<i
class=
"fa fa-users text-aqua"
></i>
5 new members joined today
</a>
</li>
</li>
</ul>
</li>
<li
class=
"footer"
><a
href=
"#"
>
View all
</a></li>
</ul>
{% endblock %}
{% block tasks %}
<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"
>
<li
class=
"header"
>
You have 9 tasks
</li>
<li>
<!-- inner menu: contains the actual data -->
<ul
class=
"menu"
>
<li>
<!-- Task item -->
<a
href=
"#"
>
<h3>
Design some buttons
<small
class=
"pull-right"
>
20%
</small>
</h3>
<div
class=
"progress xs"
>
<div
class=
"progress-bar progress-bar-aqua"
style=
"width: 20%"
role=
"progressbar"
aria-valuenow=
"20"
aria-valuemin=
"0"
aria-valuemax=
"100"
>
<span
class=
"sr-only"
>
20% Complete
</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
</ul>
</li>
<li
class=
"footer"
>
<a
href=
"#"
>
View all tasks
</a>
</li>
</ul>
{% endblock %}
{% block sidebar %}
<div
class=
"form-group"
>
<br>
<ul
class=
"sidebar-menu"
data-widget=
"tree"
>
<li>
<a
class=
"treeview "
href=
"{{ BASE_URL }}/catalog"
>
<i
class=
"fa fa-map"
></i>
<span>
Home
</span>
<span
class=
"pull-right-container"
>
<span
class=
"label label-primary pull-right"
></span>
</span>
</a>
</li>
</ul>
</div>
<!-- form-group-->
{% endblock %}
{% block user %}
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<i
class=
"fa fa-user"
></i>
<!--<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">-->
<!--<span class="hidden-xs">Alexander Pierce</span>-->
</a>
<ul
class=
"dropdown-menu"
>
<!-- User image -->
<li
class=
"user-header"
>
<!--<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">-->
<p>
{{ user.get_full_name }}
<small>
{{ user.get_username }}
</small>
</p>
</li>
<!-- Menu Body -->
<!--<li class="user-body">-->
<!--</li>-->
<!-- Menu Footer-->
<li
class=
"user-footer"
>
<div
class=
"pull-left"
>
<a
href=
"#"
class=
"btn btn-default btn-flat"
>
Profile
</a>
</div>
<div
class=
"pull-right"
>
<a
href=
"{% url 'logout' %}?next={{ request.path }}"
class=
"btn btn-default btn-flat"
>
Sign out
</a>
</div>
</li>
</ul>
{% endblock %}
{% block content %}
<!-- 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 -->
<section
class=
"content"
style=
"overflow-y: auto; height: 85vh"
>
<div
class=
"row"
>
<div
class=
"col-md-5 col-md-offset-2"
>
{% 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>
<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"
>
<i
class=
"fa fa-minus"
></i>
</button>
</div>
</div>
<div
class=
"box-body"
>
<ul
class=
"products-list product-list-in-box"
>
{% for catalog in product.catalog %}
<li
class=
"item"
>
<div
class=
"product-img"
>
<img
src=
"data:image/jpeg;base64, {{ catalog.info.img }}"
>
</div>
<div
class=
"product-info"
>
<span
class=
"product-title"
>
{{ catalog.info.identifier }}
</span>
<span
class=
"product-description"
>
{{ catalog.info.instrumentname }}
</span>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endfor %}
</div>
<div
class=
"col-md-3"
>
<div
class=
"box box-warning"
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
>
Summary
</h3>
</div>
<div
class=
"box-body"
>
<div
class=
"table-responsive"
>
<table
class=
"table"
>
<tbody>
<tr>
<th>
Total products:
</th>
<td>
{{ total_products }}
</td>
</tr>
<tr>
<th>
Total price:
</th>
<td>
${{ total_price }}
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td><button
type=
"button"
name=
"pay"
id=
"pay"
class=
"btn btn-primary"
>
Pay
</button></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- /.content -->
</div>
<!-- Footer -->
<footer
class=
" page-footer font-small special-color-dark pt-5"
>
<!-- Footer Elements -->
<div
class=
"container"
>
<!-- Social buttons
<ul class="list-unstyled list-inline text-center">
<li class="list-inline-item">
<a class="btn-floating btn-fb mx-1">
<i class="fa fa-faceboo"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-tw mx-1">
<i class="fa fa-twitter"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-gplus mx-1">
<i class="fa fa-google-plus"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-li mx-1">
<i class="fa fa-linkedin"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-dribbble mx-1">
<i class="fa fa-dribbble"> </i>
</a>
</li>
</ul>
<!-- Social buttons -->
</div>
<!-- Footer Elements -->
<!-- Copyright -->
<div
class=
"footer-copyright text-center py-3"
>
© 2018 Copyright:
<a
href=
"http://geoint.mx/"
>
Centro de Investigación en Ciencias de Información Geoespacial.
</a>
</div>
<!-- Copyright -->
</footer>
<!-- Footer -->
<!-- /.content -->
{% endblock %}
{% block scripts %}
<!-- page script -->
{% endblock %}
catalog/templates/templates.html
View file @
19cbf5c2
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
</a>
</a>
<ul
class=
"treeview-menu sidebar-form"
>
<ul
class=
"treeview-menu sidebar-form"
>
<li>
<li>
<ul
id=
"
product-list-cart-items"
class=
"control-sidebar-menu
"
></ul>
<ul
id=
"
"
class=
"control-sidebar-menu product_list_category
"
></ul>
</li>
</li>
</ul>
</ul>
</li>
</li>
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
<p></p>
<p></p>
</div>
</div>
</a>
</a>
<div
class=
"info-product-
cart-
box bg-geo"
>
<div
class=
"info-product-box bg-geo"
>
<span
class=
"info-product-box-img"
>
<span
class=
"info-product-box-img"
>
<img
src=
""
>
<img
src=
""
>
</span>
</span>
...
...
catalog/urls.py
View file @
19cbf5c2
...
@@ -12,4 +12,5 @@ urlpatterns = [
...
@@ -12,4 +12,5 @@ urlpatterns = [
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
url
(
r'^purchcartrqst/$'
,
views
.
purchaseProduct
,
name
=
'purch-prod-rqst'
),
url
(
r'^purchcartrqst/$'
,
views
.
purchaseProduct
,
name
=
'purch-prod-rqst'
),
url
(
r'^cart/$'
,
views
.
showCart
,
name
=
'show-cart'
),
]
]
catalog/views.py
View file @
19cbf5c2
...
@@ -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.
...
@@ -206,13 +208,14 @@ def getFromCart(request):
...
@@ -206,13 +208,14 @@ def getFromCart(request):
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
prod_list
=
[]
prod_list
=
[]
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'pric
e'
)
.
filter
(
user
=
user
,
purchased
=
0
)
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_dat
e'
)
.
filter
(
user
=
user
,
purchased
=
0
)
for
products
in
product_list
:
for
products
in
product_list
:
product
=
json
.
loads
(
products
[
'productList'
])
product
=
json
.
loads
(
products
[
'productList'
])
prod_list
.
append
({
prod_list
.
append
({
'purchased'
:
products
[
'purchased'
],
'purchased'
:
products
[
'purchased'
],
'price'
:
products
[
'price'
],
'price'
:
products
[
'price'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'catalog'
:
product
'catalog'
:
product
})
})
return
JsonResponse
({
'product_list'
:
prod_list
})
return
JsonResponse
({
'product_list'
:
prod_list
})
...
@@ -267,17 +270,36 @@ def purchaseProduct(request):
...
@@ -267,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'
...
@@ -286,7 +308,7 @@ def purchaseProduct(request):
...
@@ -286,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
()
...
@@ -373,3 +395,24 @@ def purchaseProduct(request):
...
@@ -373,3 +395,24 @@ def purchaseProduct(request):
# return HttpResponse(status=204)
# return HttpResponse(status=204)
#-------------------------------------------------------------------------------
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
})
\ No newline at end of file
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