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
1ab33d8d
Commit
1ab33d8d
authored
Feb 12, 2019
by
Sergio Adrian Gongora Euan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatic change to my cart was added and more description of the products
parent
def6262a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
39 deletions
+74
-39
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+54
-34
base_top.html
catalog/templates/base_top.html
+2
-2
templates.html
catalog/templates/templates.html
+13
-1
views.py
catalog/views.py
+5
-2
No files found.
catalog/static/catalog/js/dataRetrieval.js
View file @
1ab33d8d
...
@@ -66,40 +66,46 @@ var makeRequest = function (value) {
...
@@ -66,40 +66,46 @@ var makeRequest = function (value) {
});
});
};
};
var
statusUpdateCart
=
false
;
function
updateCart
(){
function
updateCart
(){
$
(
"#product-list-cart"
).
empty
();
if
(
statusUpdateCart
==
false
){
$
.
ajax
({
statusUpdateCart
=
true
;
type
:
'POST'
,
showCarProductsTabPanel
();
url
:
prod_from_cartDB_url
,
$
(
"#product-list-cart"
).
empty
();
data
:
{
$
.
ajax
({
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
type
:
'POST'
,
},
url
:
prod_from_cartDB_url
,
dataType
:
'json'
,
data
:
{
success
:
function
(
data
)
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
productsToObtain
=
[];
},
createProductContainer
(
data
.
product_list
);
dataType
:
'json'
,
data
.
product_list
.
forEach
(
function
(
products
)
{
success
:
function
(
data
)
{
let
id
=
"L-"
+
products
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
productsToObtain
=
[];
products
.
catalog
.
forEach
(
function
(
product
)
{
createProductContainer
(
data
.
product_list
);
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
data
.
product_list
.
forEach
(
function
(
products
)
{
let
id
=
"L-"
+
products
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
// filling template
products
.
catalog
.
forEach
(
function
(
product
)
{
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
// filling template
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
//document.querySelector('#product-list-cart-items').appendChild(clone_2);
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
document
.
querySelector
(
'#'
+
id
).
appendChild
(
clone_2
);
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
//document.querySelector('#product-list-cart-items').appendChild(clone_2);
document
.
querySelector
(
'#'
+
id
).
appendChild
(
clone_2
);
});
});
});
});
statusUpdateCart
=
false
;
}
}
});
});
}
};
};
function
deleteProductCar
(
element
){
function
deleteProductCar
(
element
){
...
@@ -246,8 +252,14 @@ function createProductContainer(products) {
...
@@ -246,8 +252,14 @@ function createProductContainer(products) {
products
.
forEach
(
function
(
list
){
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
,
"-"
);
let
name
=
list
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
temp_1
.
content
.
querySelector
(
'span'
).
id
=
list
.
id
;
let
startDate
=
new
Date
(
list
.
startDate
).
toUTCString
().
split
(
' '
).
slice
(
0
,
4
).
join
(
' '
);
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
list
.
aggreg_date
;
let
endDate
=
new
Date
(
list
.
endDate
).
toUTCString
().
split
(
' '
).
slice
(
0
,
4
).
join
(
' '
);
temp_1
.
content
.
querySelectorAll
(
'span'
)[
0
].
id
=
list
.
id
;
temp_1
.
content
.
querySelectorAll
(
'span'
)[
0
].
textContent
=
list
.
aggreg_date
;
temp_1
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
list
.
process
;
temp_1
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
startDate
;
temp_1
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
endDate
;
temp_1
.
content
.
querySelector
(
'ul .control-sidebar-menu'
).
id
=
"L-"
+
name
;
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
);
...
@@ -320,6 +332,14 @@ function showProductTabPane() {
...
@@ -320,6 +332,14 @@ function showProductTabPane() {
$
(
'aside'
).
addClass
(
"control-sidebar-open"
);
$
(
'aside'
).
addClass
(
"control-sidebar-open"
);
}
}
function
showCarProductsTabPanel
(){
$
(
'#cart'
).
addClass
(
"active"
);
$
(
'#globe'
).
removeClass
(
"active"
);
$
(
'#control-sidebar-settings-tab'
).
addClass
(
"active"
);
$
(
'#control-sidebar-home-tab'
).
removeClass
(
"active"
);
$
(
'aside'
).
addClass
(
"control-sidebar-open"
);
}
function
showWaitingModal
()
{
function
showWaitingModal
()
{
$
(
"body"
).
addClass
(
'loading'
)
$
(
"body"
).
addClass
(
'loading'
)
$
(
"#product-list-toggle"
).
addClass
(
'not-active'
)
$
(
"#product-list-toggle"
).
addClass
(
'not-active'
)
...
...
catalog/templates/base_top.html
View file @
1ab33d8d
...
@@ -104,14 +104,14 @@
...
@@ -104,14 +104,14 @@
<aside
class=
"control-sidebar control-sidebar-dark"
>
<aside
class=
"control-sidebar control-sidebar-dark"
>
<!-- 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"
class=
"active"
><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"
onclick=
"updateCart()"
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 -->
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
<!-- Home tab content -->
<!-- Home tab content -->
<div
class=
"tab-pane"
id=
"control-sidebar-home-tab"
>
<div
class=
"tab-pane
active
"
id=
"control-sidebar-home-tab"
>
<form
id=
'product-to-cart-form'
role=
"form"
method=
"post"
>
<form
id=
'product-to-cart-form'
role=
"form"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
<div
class=
"container"
>
<div
class=
"container"
>
...
...
catalog/templates/templates.html
View file @
1ab33d8d
...
@@ -73,8 +73,20 @@
...
@@ -73,8 +73,20 @@
<li
class=
"treeview"
>
<li
class=
"treeview"
>
<a
href=
"#"
>
<a
href=
"#"
>
<i
class=
"fa fa-cubes"
></i>
<i
class=
"fa fa-cubes"
></i>
<span></span>
<span
id=
""
></span>
<i
class=
"glyphicon glyphicon-remove"
style=
"padding-left: 15px"
onclick=
"deleteProductCar(this);"
></i>
<i
class=
"glyphicon glyphicon-remove"
style=
"padding-left: 15px"
onclick=
"deleteProductCar(this);"
></i>
<div>
<label>
Process:
</label>
<span></span>
</div>
<div>
<label>
Start Date:
</label>
<span></span>
</div>
<div>
<label>
End Date:
</label>
<span></span>
</div>
<span
class=
"pull-right-container"
>
<span
class=
"pull-right-container"
>
<span
class=
"label label-primary pull-right"
></span>
<span
class=
"label label-primary pull-right"
></span>
</span>
</span>
...
...
catalog/views.py
View file @
1ab33d8d
...
@@ -237,8 +237,8 @@ def getFromCart(request):
...
@@ -237,8 +237,8 @@ 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'
,
'price'
,
'aggreg_date'
,
'id'
)
.
filter
(
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_date'
,
'id'
,
user
=
user
,
purchased
=
0
)
'search__process__name'
,
'search__startDate'
,
'search__endDate'
)
.
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'
])
...
@@ -247,6 +247,9 @@ def getFromCart(request):
...
@@ -247,6 +247,9 @@ def getFromCart(request):
'price'
:
products
[
'price'
],
'price'
:
products
[
'price'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'id'
:
products
[
'id'
],
'id'
:
products
[
'id'
],
'process'
:
products
[
'search__process__name'
],
'startDate'
:
products
[
'search__startDate'
],
'endDate'
:
products
[
'search__endDate'
],
'catalog'
:
product
'catalog'
:
product
})
})
return
JsonResponse
({
'product_list'
:
prod_list
})
return
JsonResponse
({
'product_list'
:
prod_list
})
...
...
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