Skip to content
Snippets Groups Projects
Commit 32dab41a authored by Thomas Roos's avatar Thomas Roos
Browse files

Expand feedback get api with used parameter

parent 2b44a5bb
No related branches found
No related tags found
No related merge requests found
""" REST api for problems """
from flask_restful import Resource
from flask_restful import Resource, reqparse
from pony import orm
......@@ -35,3 +35,34 @@ class Feedback(Resource):
}
for fb in FeedbackOption.select(lambda fb: fb.problem == problem)
]
post_parser = reqparse.RequestParser()
post_parser.add_argument('name', type=str, required=True)
post_parser.add_argument('description', type=str, required=True)
post_parser.add_argument('score', type=int, required=True)
@orm.db_session
def post(self, problem_id):
"""Post a new feedback option
Parameters
----------
name: str
description: str
score: int
"""
problem = Problem[problem_id]
args = self.post_parser.parse_args()
fb = FeedbackOption(problem = problem, text = args.name, description = args.description, score = args.score)
orm.commit();
return {
'id': fb.id,
'name': fb.text,
'description': fb.description,
'score': fb.score
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment