Merge pull request #5515 from jangsutsr/3254_update_host_detail_put_option

Update host detail put option rework
This commit is contained in:
Aaron Tan
2017-02-24 16:58:09 -05:00
committed by GitHub

View File

@@ -123,19 +123,20 @@ class Metadata(metadata.SimpleMetadata):
actions = {} actions = {}
for method in {'GET', 'PUT', 'POST'} & set(view.allowed_methods): for method in {'GET', 'PUT', 'POST'} & set(view.allowed_methods):
view.request = clone_request(request, method) view.request = clone_request(request, method)
obj = None
try: try:
# Test global permissions # Test global permissions
if hasattr(view, 'check_permissions'): if hasattr(view, 'check_permissions'):
view.check_permissions(view.request) view.check_permissions(view.request)
# Test object permissions # Test object permissions
if method == 'PUT' and hasattr(view, 'get_object'): if method == 'PUT' and hasattr(view, 'get_object'):
view.get_object() obj = view.get_object()
except (exceptions.APIException, PermissionDenied, Http404): except (exceptions.APIException, PermissionDenied, Http404):
continue continue
else: else:
# If user has appropriate permissions for the view, include # If user has appropriate permissions for the view, include
# appropriate metadata about the fields that should be supplied. # appropriate metadata about the fields that should be supplied.
serializer = view.get_serializer() serializer = view.get_serializer(instance=obj)
actions[method] = self.get_serializer_info(serializer) actions[method] = self.get_serializer_info(serializer)
finally: finally:
view.request = request view.request = request