Fix up some serious issues posting new surveys and deleting them by

non-super users.   Also fix up some issues checking can_change for job
templates for operations like PATCH where not all of the data points
will be submitted
This commit is contained in:
Matthew Jones
2015-01-27 15:11:54 -05:00
parent 6fba494692
commit 20910e0e95
3 changed files with 41 additions and 1 deletions

View File

@@ -1493,6 +1493,7 @@ class JobTemplateSchedulesList(SubListCreateAPIView):
class JobTemplateSurveySpec(GenericAPIView):
model = JobTemplate
parent_model = JobTemplate
# FIXME: Add serializer class to define fields in OPTIONS request!
def get(self, request, *args, **kwargs):
@@ -1537,6 +1538,8 @@ class JobTemplateSurveySpec(GenericAPIView):
def delete(self, request, *args, **kwargs):
obj = self.get_object()
if not request.user.can_access(self.model, 'delete', obj):
raise PermissionDenied()
obj.survey_spec = {}
obj.save()
return Response()