Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-Canteeneo
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
Willard Torres
CS123-Canteeneo
Commits
6c93b87c
Commit
6c93b87c
authored
Oct 28, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add favorite toggle for dish and stall
parent
fec6a8dc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
api.py
canteeneo/api.py
+16
-4
No files found.
canteeneo/api.py
View file @
6c93b87c
...
@@ -93,20 +93,32 @@ def get_auth_token():
...
@@ -93,20 +93,32 @@ def get_auth_token():
token
=
generate_token
(
g
.
user
)
token
=
generate_token
(
g
.
user
)
return
jsonify
({
'token'
:
token
.
decode
(
'ascii'
),
'duration'
:
600
})
return
jsonify
({
'token'
:
token
.
decode
(
'ascii'
),
'duration'
:
600
})
@
app
.
route
(
'/api/dish/<int:dish_id>/favorite'
,
methods
=
[
'
POS
T'
])
@
app
.
route
(
'/api/dish/<int:dish_id>/favorite'
,
methods
=
[
'
GE
T'
])
@
auth
.
login_required
@
auth
.
login_required
def
favorite_dish
(
dish_id
):
def
favorite_dish
(
dish_id
):
pass
dish
=
Dish
.
query
.
get
(
dish_id
)
if
dish
not
in
g
.
user
.
dish_favorites
:
g
.
user
.
dish_favorites
.
append
(
dish
)
else
:
g
.
user
.
dish_favorites
.
remove
(
dish
)
db
.
session
.
commit
()
return
str
(
dish
in
g
.
user
.
dish_favorites
)
@
app
.
route
(
'/api/dish/<int:dish_id>/review'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/api/dish/<int:dish_id>/review'
,
methods
=
[
'POST'
])
@
auth
.
login_required
@
auth
.
login_required
def
review_dish
(
dish_id
):
def
review_dish
(
dish_id
):
pass
pass
@
app
.
route
(
'/api/stall/<int:stall_id>/favorite'
,
methods
=
[
'
POS
T'
])
@
app
.
route
(
'/api/stall/<int:stall_id>/favorite'
,
methods
=
[
'
GE
T'
])
@
auth
.
login_required
@
auth
.
login_required
def
favorite_stall
(
stall_id
):
def
favorite_stall
(
stall_id
):
pass
stall
=
Stall
.
query
.
get
(
stall_id
)
if
stall
not
in
g
.
user
.
stall_favorites
:
g
.
user
.
stall_favorites
.
append
(
stall
)
else
:
g
.
user
.
stall_favorites
.
remove
(
stall
)
db
.
session
.
commit
()
return
str
(
stall
in
g
.
user
.
stall_favorites
)
@
app
.
route
(
'/api/stall/<int:stall_id>/review'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/api/stall/<int:stall_id>/review'
,
methods
=
[
'POST'
])
@
auth
.
login_required
@
auth
.
login_required
...
...
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