Skip to content

Commit

Permalink
fix resolve conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 23, 2017
1 parent ae7c95b commit 9956daf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions rdmo/projects/tests/test_viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class ValueTests(TestViewsetMixin, TestSingleObjectMixin, ProjectsViewsetTestCas
},
'delete_viewset': {
'owner': 204, 'manager': 204, 'author': 204, 'guest': 403, 'user': 403, 'anonymous': 403
},
'resolve_viewset': {
'owner': 200, 'manager': 200, 'author': 200, 'guest': 200, 'user': 403, 'anonymous': 403
}
}

Expand Down Expand Up @@ -119,6 +122,13 @@ def _test_delete_viewset(self, username):
})
instance.save(update_fields=None)

def _test_resolve_viewset(self, username):
for instance in self.instances:
self.assert_viewset('resolve_viewset', 'get', 'resolve', username, query_params={
'project': self.project_id,
'condition': 1
})


class QuestionEntityTests(TestReadOnlyModelViewsetMixin, ProjectsViewsetTestCase):

Expand Down
3 changes: 1 addition & 2 deletions rdmo/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def dispatch(self, request, *args, **kwargs):

@list_route()
def resolve(self, request):
if not request.user.has_perm('projects.view_value', self.project):
self.permission_denied(request)
self.project = self.get_project(request)

condition = self.get_condition(request)
return Response({'result': condition.resolve(self.project, self.snapshot)})
Expand Down

0 comments on commit 9956daf

Please sign in to comment.