1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

API fixes for 500 errors.

This commit is contained in:
Chris Church 2016-02-24 18:38:04 -05:00
parent 5b89c5e126
commit a2595dcf12
3 changed files with 12 additions and 5 deletions

View File

@ -478,6 +478,10 @@ class BaseSerializer(serializers.ModelSerializer):
return attrs
class EmptySerializer(serializers.Serializer):
pass
class BaseFactSerializer(DocumentSerializer):
__metaclass__ = BaseSerializerMetaclass

View File

@ -1940,7 +1940,7 @@ class JobTemplateSurveySpec(GenericAPIView):
model = JobTemplate
parent_model = JobTemplate
# FIXME: Add serializer class to define fields in OPTIONS request!
serializer_class = EmptySerializer
def get(self, request, *args, **kwargs):
obj = self.get_object()
@ -2019,8 +2019,8 @@ class JobTemplateActivityStreamList(SubListAPIView):
class JobTemplateCallback(GenericAPIView):
model = JobTemplate
# FIXME: Add serializer class to define fields in OPTIONS request!
permission_classes = (JobTemplateCallbackPermission,)
serializer_class = EmptySerializer
@csrf_exempt
@transaction.non_atomic_requests
@ -2202,7 +2202,7 @@ class SystemJobTemplateDetail(RetrieveAPIView):
class SystemJobTemplateLaunch(GenericAPIView):
model = SystemJobTemplate
# FIXME: Add serializer class to define fields in OPTIONS request!
serializer_class = EmptySerializer
def get(self, request, *args, **kwargs):
return Response({})
@ -2273,7 +2273,7 @@ class JobActivityStreamList(SubListAPIView):
class JobStart(GenericAPIView):
model = Job
# FIXME: Add serializer class to define fields in OPTIONS request!
serializer_class = EmptySerializer
is_job_start = True
def get(self, request, *args, **kwargs):

View File

@ -34,7 +34,10 @@ def handle_error(request, status=404, **kwargs):
status_code = status
default_detail = kwargs['content']
api_error_view = ApiErrorView.as_view(view_name=kwargs['name'], exception_class=APIException)
return api_error_view(request)
response = api_error_view(request)
if hasattr(response, 'render'):
response.render()
return response
else:
kwargs['content'] = format_html('<span class="nocode">{}</span>', kwargs.get('content', ''))
return render(request, 'error.html', kwargs, status=status)