|
1 |
| -import json |
| 1 | +"""Views for comments app.""" |
2 | 2 |
|
3 | 3 | from django.contrib.auth.decorators import login_required
|
4 |
| -from django.http.response import HttpResponseRedirect |
5 | 4 | from django.shortcuts import render_to_response
|
6 | 5 | from django.template import RequestContext
|
7 | 6 | from django.utils.decorators import method_decorator
|
|
14 | 13 | detail_route
|
15 | 14 | )
|
16 | 15 | from rest_framework.exceptions import ParseError
|
17 |
| -from rest_framework.permissions import IsAuthenticated |
18 | 16 | from rest_framework.renderers import JSONRenderer
|
19 | 17 | from rest_framework.response import Response
|
20 |
| -from rest_framework.serializers import ModelSerializer, Serializer |
21 | 18 | from rest_framework.viewsets import ModelViewSet
|
22 | 19 | from sphinx.websupport import WebSupport
|
23 | 20 |
|
24 | 21 | from readthedocs.comments.models import (
|
25 | 22 | DocumentComment, DocumentNode, NodeSnapshot, DocumentCommentSerializer,
|
26 | 23 | DocumentNodeSerializer, ModerationActionSerializer)
|
27 |
| -from readthedocs.privacy.backend import AdminNotAuthorized |
28 | 24 | from readthedocs.projects.models import Project
|
29 |
| -from readthedocs.restapi.permissions import IsOwner, CommentModeratorOrReadOnly |
| 25 | +from readthedocs.restapi.permissions import CommentModeratorOrReadOnly |
30 | 26 |
|
31 | 27 | from .backend import DjangoStorage
|
32 | 28 | from .session import UnsafeSessionAuthentication
|
|
48 | 44 | @api_view(['GET'])
|
49 | 45 | @permission_classes([permissions.IsAuthenticatedOrReadOnly])
|
50 | 46 | @renderer_classes((JSONRenderer,))
|
51 |
| -def get_options(request): |
| 47 | +def get_options(request): # pylint: disable=unused-argument |
52 | 48 | base_opts = support.base_comment_opts
|
53 | 49 | base_opts['addCommentURL'] = '/api/v2/comments/'
|
54 | 50 | base_opts['getCommentsURL'] = '/api/v2/comments/'
|
@@ -88,11 +84,11 @@ def attach_comment(request):
|
88 | 84 | # Normal Views
|
89 | 85 | #######
|
90 | 86 |
|
91 |
| -def build(request): |
| 87 | +def build(request): # pylint: disable=unused-argument |
92 | 88 | support.build()
|
93 | 89 |
|
94 | 90 |
|
95 |
| -def serve_file(request, file): |
| 91 | +def serve_file(request, file): # pylint: disable=redefined-builtin |
96 | 92 | document = support.get_document(file)
|
97 | 93 |
|
98 | 94 | return render_to_response('doc.html',
|
@@ -158,6 +154,9 @@ def update_node(request):
|
158 | 154 |
|
159 | 155 |
|
160 | 156 | class CommentViewSet(ModelViewSet):
|
| 157 | + |
| 158 | + """Viewset for Comment model.""" |
| 159 | + |
161 | 160 | serializer_class = DocumentCommentSerializer
|
162 | 161 | permission_classes = [CommentModeratorOrReadOnly, permissions.IsAuthenticatedOrReadOnly]
|
163 | 162 |
|
@@ -199,7 +198,7 @@ def create(self, request):
|
199 | 198 | return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
200 | 199 |
|
201 | 200 | @detail_route(methods=['put'])
|
202 |
| - def moderate(self, request, pk): |
| 201 | + def moderate(self, request, pk): # pylint: disable=unused-argument |
203 | 202 | comment = self.get_object()
|
204 | 203 | decision = request.data['decision']
|
205 | 204 | moderation_action = comment.moderate(request.user, decision)
|
|
0 commit comments