Skip to content

Commit

Permalink
Remove permission for Xform API view
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Nov 28, 2016
1 parent 61c4389 commit ef1cfd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cadasta/questionnaires/renderer/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def transform_to_xform_json(self, data):
data.get('question_groups', []))
json['children'] = sorted(questions + question_groups,
key=lambda x: x['index'])
for c in json['children']:
print(c['name'], c.get('index', "nothing"))
return json

def insert_version_attribute(self, xform, root_node, version):
Expand Down
9 changes: 6 additions & 3 deletions cadasta/questionnaires/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from rest_framework import generics, mixins, status
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer, BrowsableAPIRenderer
from rest_framework.permissions import IsAuthenticated
from tutelary.mixins import APIPermissionRequiredMixin

from organization.models import Project
Expand All @@ -18,7 +17,11 @@ class QuestionnaireDetail(APIPermissionRequiredMixin,
mixins.CreateModelMixin,
generics.RetrieveUpdateAPIView):
renderer_classes = (JSONRenderer, BrowsableAPIRenderer, XFormRenderer, )
permission_classes = (IsAuthenticated,)

def get_actions(self, request):
if request.GET.get('format') == 'xform':
return None
return 'questionnaire.view'

def patch_actions(self, request):
try:
Expand All @@ -28,7 +31,7 @@ def patch_actions(self, request):

serializer_class = QuestionnaireSerializer
permission_required = {
'GET': 'questionnaire.view',
'GET': get_actions,
'PUT': patch_actions,
}

Expand Down

0 comments on commit ef1cfd6

Please sign in to comment.