1 | |||
2 | from flask import request |
||
3 | from flask_restplus import Resource |
||
4 | from skf.api.security import security_headers, validate_privilege, select_userid_jwt |
||
5 | from skf.api.comment.business import new_comment_item |
||
6 | from skf.api.comment.serializers import comment, comment_new, message |
||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
7 | from skf.api.comment.parsers import authorization |
||
8 | from skf.api.restplus import api |
||
9 | |||
10 | ns = api.namespace('comment', description='Operations related to comment items') |
||
11 | |||
12 | |||
13 | @ns.route('/new') |
||
14 | @api.response(404, 'Validation error', message) |
||
15 | class CommentItemNew(Resource): |
||
16 | |||
17 | @api.expect(authorization, comment_new) |
||
18 | @api.marshal_with(message, 'Success') |
||
19 | @api.response(400, 'No results found', message) |
||
20 | def put(self): |
||
21 | """ |
||
22 | Create a comment item. |
||
23 | * Privileges required: **edit** |
||
24 | """ |
||
25 | validate_privilege(self, 'edit') |
||
26 | user_id = select_userid_jwt(self) |
||
27 | data = request.json |
||
28 | result = new_comment_item(user_id, data) |
||
29 | return result, 200, security_headers() |
||
30 | |||
31 |