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
a310ed97
Commit
a310ed97
authored
Dec 02, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove stall favorite count route, fix dish favorites
parent
134fe888
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
api.py
canteeneo/api.py
+6
-10
No files found.
canteeneo/api.py
View file @
a310ed97
...
...
@@ -108,13 +108,16 @@ def unauthorized():
def
dish_favorite
(
dish_id
):
dish
=
Dish
.
query
.
get
(
dish_id
)
if
request
.
method
==
'POST'
:
favorited
=
request
.
form
[
'favorited'
]
==
u'1
'
favorited
=
request
.
form
[
'favorited'
]
==
'true
'
if
dish
not
in
g
.
user
.
dish_Favorites
and
favorited
:
g
.
user
.
dish_
F
avorites
.
append
(
dish
)
g
.
user
.
dish_
f
avorites
.
append
(
dish
)
elif
dish
in
g
.
user
.
dish_favorites
and
not
favorited
:
g
.
user
.
dish_favorites
.
remove
(
dish
)
db
.
session
.
commit
()
return
str
(
dish
in
g
.
user
.
dish_favorites
)
return
jsonify
({
'count'
:
len
(
dish
.
favorites
),
'favorited'
:
dish
in
g
.
user
.
dish_favorites
})
@
app
.
route
(
'/api/dishes/<int:dish_id>/reviews'
,
methods
=
[
'POST'
])
@
auth
.
login_required
...
...
@@ -144,13 +147,6 @@ def get_stall_by_name():
name
=
request
.
args
.
get
(
'name'
)
return
jsonify
(
stall_obj
(
Stall
.
query
.
filter_by
(
name
=
name
)
.
first
()))
@
app
.
route
(
'/api/stalls/<int:stall_id>/favorites/count'
,
methods
=
[
'GET'
])
def
get_stall_favorites_count
(
stall_id
):
stall
=
Stall
.
query
.
get
(
stall_id
)
if
(
stall
is
None
):
return
0
return
str
(
len
(
stall
.
favorites
))
@
app
.
route
(
'/api/stalls/<int:stall_id>/dishes'
,
methods
=
[
'GET'
])
def
get_dishes_by_stall
(
stall_id
):
dishes
=
[]
...
...
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