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
b0c8b37c
Commit
b0c8b37c
authored
Feb 08, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- activacion del boton 'Pay'
- se muestra el proceso en la lista de reportes
parent
bc00fc8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
+22
-13
show_cart.html
catalog/templates/show_cart.html
+1
-1
urls.py
catalog/urls.py
+1
-0
views.py
catalog/views.py
+17
-11
views.py
reports/views.py
+3
-1
No files found.
catalog/templates/show_cart.html
View file @
b0c8b37c
...
...
@@ -193,7 +193,7 @@
</tbody>
<tfoot>
<tr>
<td><
button
type=
"button"
name=
"pay"
id=
"pay"
class=
"btn btn-primary"
>
Pay
</button
></td>
<td><
a
href=
"../pay"
class=
"btn btn-primary"
>
Pay
</a
></td>
</tr>
</tfoot>
</table>
...
...
catalog/urls.py
View file @
b0c8b37c
...
...
@@ -14,4 +14,5 @@ urlpatterns = [
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'
),
url
(
r'^pay/$'
,
views
.
Pay
,
name
=
'pay'
),
]
catalog/views.py
View file @
b0c8b37c
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
catalog.forms
import
ASFSearchForm
from
catalog.models
import
Polygon
,
CartProduct
,
Product_l1c
,
Search
,
Purchase
,
Process
from
django.http
import
HttpResponse
,
JsonResponse
,
HttpResponseRedirect
...
...
@@ -440,18 +440,19 @@ def showCart(request):
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
)
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
)
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'
])
#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'])
print
(
values
[
'id'
])
username
=
values
[
'user__username'
]
useremail
=
values
[
'user__email'
]
...
...
@@ -487,7 +488,7 @@ def showCart(request):
#json_data = json.dumps(data, indent=4,sort_keys=True)
#formatea el json
json_data
=
json
.
dumps
(
data
,
indent
=
4
)
print
(
json_data
)
#
print(json_data)
#escribe el json en el archivo
fidProductsFile
=
open
(
search_dir
+
"/findProducts.json"
,
"w"
)
fidProductsFile
.
write
(
json_data
)
...
...
@@ -532,3 +533,8 @@ def showCart(request):
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
)
return
redirect
(
'../../reports'
)
\ No newline at end of file
reports/views.py
View file @
b0c8b37c
...
...
@@ -64,12 +64,14 @@ def report_L2ASCL(request, report,purchase_id):
def
Reports
(
request
):
productList
=
[]
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
)
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
1
)
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
,
'search__process_id__name'
)
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
1
)
print
(
product_list
)
for
producto
in
product_list
:
size
=
0
for
p
in
json
.
loads
(
producto
[
'productList'
]):
size
=
size
+
float
(
p
[
'info'
][
'size'
][:
-
3
])
productList
.
append
({
"process"
:
producto
[
'search__process_id__name'
],
"purchase_date"
:
producto
[
'aggreg_date'
],
"startDate"
:
producto
[
'search__startDate'
],
"endDate"
:
producto
[
'search__endDate'
],
...
...
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