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
f63292f2
Commit
f63292f2
authored
Nov 05, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add review endpoints
parent
48b8c71a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
api.py
canteeneo/api.py
+16
-3
No files found.
canteeneo/api.py
View file @
f63292f2
from
canteeneo
import
app
,
db
,
auth
from
flask
import
jsonify
,
request
,
g
from
models
import
Dish
,
Stall
,
Location
,
User
from
models
import
Dish
,
Stall
,
Location
,
User
,
DishReview
,
StallReview
from
datetime
import
datetime
from
itsdangerous
import
TimedJSONWebSignatureSerializer
as
Serializer
,
BadSignature
,
SignatureExpired
...
...
@@ -107,7 +107,14 @@ def favorite_dish(dish_id):
@
app
.
route
(
'/api/dish/<int:dish_id>/review'
,
methods
=
[
'POST'
])
@
auth
.
login_required
def
review_dish
(
dish_id
):
pass
user_id
=
g
.
user
.
id
title
=
request
.
form
[
'title'
]
body
=
request
.
form
[
'body'
]
rating
=
int
(
request
.
form
[
'rating'
])
db
.
session
.
add
(
DishReview
(
title
,
body
,
rating
,
user_id
,
dish_id
))
db
.
session
.
commit
()
return
'Review posted'
@
app
.
route
(
'/api/stall/<int:stall_id>/favorite'
,
methods
=
[
'GET'
])
@
auth
.
login_required
...
...
@@ -123,4 +130,10 @@ def favorite_stall(stall_id):
@
app
.
route
(
'/api/stall/<int:stall_id>/review'
,
methods
=
[
'POST'
])
@
auth
.
login_required
def
review_stall
(
stall_id
):
pass
user_id
=
g
.
user
.
id
title
=
request
.
form
[
'title'
]
body
=
request
.
form
[
'body'
]
rating
=
int
(
request
.
form
[
'rating'
])
db
.
session
.
add
(
StallReview
(
title
,
body
,
rating
,
user_id
,
stall_id
))
db
.
session
.
commit
()
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