Backport ACL computation improvements
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -33,6 +33,26 @@ def encapsulate(function):
|
||||
return lambda: function
|
||||
|
||||
|
||||
def get_related_field(model, related_field_name):
|
||||
try:
|
||||
local_field_name, remaining_field_path = related_field_name.split(
|
||||
LOOKUP_SEP, 1
|
||||
)
|
||||
except ValueError:
|
||||
local_field_name = related_field_name
|
||||
remaining_field_path = None
|
||||
|
||||
related_field = model._meta.get_field(local_field_name)
|
||||
|
||||
if remaining_field_path:
|
||||
return get_related_field(
|
||||
model=related_field.related_model,
|
||||
related_field_name=remaining_field_path
|
||||
)
|
||||
|
||||
return related_field
|
||||
|
||||
|
||||
def introspect_attribute(attribute_name, obj):
|
||||
"""
|
||||
Resolve the attribute of model. Supports nested reference using dotted
|
||||
|
||||
Reference in New Issue
Block a user