Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flask-book-shoppe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joel Vinay Kumar
flask-book-shoppe
Commits
e801c181
Commit
e801c181
authored
Apr 02, 2018
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes done
parent
9d94b061
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
book_shoppe.py
book_shoppe.py
+7
-3
bookshopper.db
bookshopper.db
+0
-0
No files found.
book_shoppe.py
View file @
e801c181
...
...
@@ -152,12 +152,15 @@ def login():
error
=
'Invalid credentials'
return
render_template
(
'login.html'
,
error
=
error
)
bill
=
0
@
app
.
route
(
'/cart'
,
methods
=
[
'GET'
,
'POST'
])
def
cart
():
if
request
.
method
==
'GET'
:
session
[
'log_count'
]
=
len
(
CurrentCart
.
query
.
all
())
dp
=
CurrentCart
.
query
.
all
()
sum
=
0
global
bill
for
d
in
dp
:
sum
+=
((
d
.
__dict__
[
"price"
])
*
(
d
.
__dict__
[
"quantity"
]))
bill
=
sum
+
sum
//
10
...
...
@@ -170,6 +173,7 @@ def cart():
orders
=
[]
order_no
=
1
@
app
.
route
(
'/show_orders'
,
methods
=
[
'GET'
,
'POST'
])
def
show_orders
():
session
[
'log_count'
]
=
len
(
CurrentCart
.
query
.
all
())
...
...
@@ -185,8 +189,7 @@ def show_orders():
db
.
session
.
commit
()
order_no
+=
1
orders
.
append
(
cart_collection
)
for
x
in
orders
:
print
(
x
)
for
cart_item
in
cartx
:
db
.
session
.
delete
(
cart_item
)
db
.
session
.
commit
()
...
...
@@ -202,13 +205,14 @@ def show_orders():
def
clear_cart
():
session
[
'log_count'
]
=
len
(
CurrentCart
.
query
.
all
())
total
=
0
bill
=
0
cart_items
=
CurrentCart
.
query
.
all
()
for
cart_item
in
cart_items
:
db
.
session
.
delete
(
cart_item
)
db
.
session
.
commit
()
flash
(
"You just cleared the cart!!"
)
session
[
'log_count'
]
=
len
(
CurrentCart
.
query
.
all
())
return
render_template
(
'cart.html'
,
size
=
len
(
data
[
'items'
]),
data
=
data
,
items
=
CurrentCart
.
query
.
all
(),
total
=
total
)
return
render_template
(
'cart.html'
,
size
=
len
(
data
[
'items'
]),
data
=
data
,
items
=
CurrentCart
.
query
.
all
(),
total
=
total
,
bill
=
bill
)
with
open
(
"json/catalog.json"
)
as
data_file
:
data
=
json
.
loads
(
data_file
.
read
())
...
...
bookshopper.db
View file @
e801c181
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