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
7d6260a0
Commit
7d6260a0
authored
Dec 01, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix embarrasing Stall and StallFavorite errors
parent
cdb9a728
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
api.py
canteeneo/api.py
+11
-4
models.py
canteeneo/models.py
+1
-1
No files found.
canteeneo/api.py
View file @
7d6260a0
...
...
@@ -144,6 +144,13 @@ 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
len
(
stall
.
favorites
)
@
app
.
route
(
'/api/stalls/<int:stall_id>/dishes'
,
methods
=
[
'GET'
])
def
get_dishes_by_stall
(
stall_id
):
dishes
=
[]
...
...
@@ -164,11 +171,11 @@ def stall_favorite(stall_id):
if
request
.
method
==
'POST'
:
favorited
=
request
.
form
[
'favorited'
]
==
u'1'
if
stall
not
in
g
.
user
.
stall_favorites
and
favorited
:
g
.
user
.
stall_favorites
.
append
(
dish
)
elif
dish
in
g
.
user
.
dish
_favorites
and
not
favorited
:
g
.
stall
.
stall_favorites
.
remove
(
dish
)
g
.
user
.
stall_favorites
.
append
(
stall
)
elif
stall
in
g
.
user
.
stall
_favorites
and
not
favorited
:
g
.
stall
.
stall_favorites
.
remove
(
stall
)
db
.
session
.
commit
()
return
str
(
dish
in
g
.
user
.
stall_favorites
)
return
str
(
stall
in
g
.
user
.
stall_favorites
)
@
app
.
route
(
'/api/stalls/<int:stall_id>/reviews'
,
methods
=
[
'POST'
])
@
auth
.
login_required
...
...
canteeneo/models.py
View file @
7d6260a0
...
...
@@ -18,7 +18,7 @@ class Stall(db.Model):
owner_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'owner.id'
))
location_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'location.id'
))
dishes
=
db
.
relationship
(
'Dish'
,
backref
=
'stall'
,
cascade
=
'all,delete'
,
lazy
=
'dynamic'
)
favorites
=
db
.
relationship
(
'
Stall
'
,
secondary
=
stall_favorites
,
backref
=
db
.
backref
(
'stall'
,
lazy
=
'dynamic'
))
favorites
=
db
.
relationship
(
'
User
'
,
secondary
=
stall_favorites
,
backref
=
db
.
backref
(
'stall'
,
lazy
=
'dynamic'
))
reviews
=
db
.
relationship
(
'StallReview'
,
backref
=
'stall'
,
lazy
=
'dynamic'
)
def
__init__
(
self
,
name
,
description
,
owner_id
,
location_id
):
...
...
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