mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 05:19:15 +02:00
"[EPIC] Report option on everything - reports models
This commit is contained in:
parent
079671ef7a
commit
a6cf2ce019
22 changed files with 792 additions and 21 deletions
|
@ -154,7 +154,7 @@ def order_for_search(qs, field):
|
|||
|
||||
def recursive_getattr(obj, key, permissive=False):
|
||||
"""
|
||||
Given a dictionary such as {'user': {'name': 'Bob'}} and
|
||||
Given a dictionary such as {'user': {'name': 'Bob'}} or and object and
|
||||
a dotted string such as user.name, returns 'Bob'.
|
||||
|
||||
If the value is not present, returns None
|
||||
|
@ -162,7 +162,10 @@ def recursive_getattr(obj, key, permissive=False):
|
|||
v = obj
|
||||
for k in key.split("."):
|
||||
try:
|
||||
v = v.get(k)
|
||||
if hasattr(v, "get"):
|
||||
v = v.get(k)
|
||||
else:
|
||||
v = getattr(v, k)
|
||||
except (TypeError, AttributeError):
|
||||
if not permissive:
|
||||
raise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue