Completed
Push — master ( 739b7a...711b3d )
by Glenn
01:21
created

CommentItemNew   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 17
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A put() 0 13 1
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
Unused comment imported from skf.api.comment.serializers
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