MCPcopy
hub / github.com/encode/django-rest-framework / determine_actions

Method determine_actions

rest_framework/metadata.py:72–97  ·  view source on GitHub ↗

For generic class based views we return information about the fields that are accepted for 'PUT' and 'POST' methods.

(self, request, view)

Source from the content-addressed store, hash-verified

70 return metadata
71
72 def determine_actions(self, request, view):
73 """
74 For generic class based views we return information about
75 the fields that are accepted for 'PUT' and 'POST' methods.
76 """
77 actions = {}
78 for method in {'PUT', 'POST'} & set(view.allowed_methods):
79 view.request = clone_request(request, method)
80 try:
81 # Test global permissions
82 if hasattr(view, 'check_permissions'):
83 view.check_permissions(view.request)
84 # Test object permissions
85 if method == 'PUT' and hasattr(view, 'get_object'):
86 view.get_object()
87 except (exceptions.APIException, PermissionDenied, Http404):
88 pass
89 else:
90 # If user has appropriate permissions for the view, include
91 # appropriate metadata about the fields that should be supplied.
92 serializer = view.get_serializer()
93 actions[method] = self.get_serializer_info(serializer)
94 finally:
95 view.request = request
96
97 return actions
98
99 def get_serializer_info(self, serializer):
100 """

Callers 1

determine_metadataMethod · 0.95

Calls 5

get_serializer_infoMethod · 0.95
clone_requestFunction · 0.90
check_permissionsMethod · 0.45
get_objectMethod · 0.45
get_serializerMethod · 0.45

Tested by

no test coverage detected