mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
12589 review changes - permission proxy
This commit is contained in:
parent
002c0bf4be
commit
6a98397626
@ -18,11 +18,16 @@ def get_permission_for_model(model, action):
|
||||
:param model: A model or instance
|
||||
:param action: View, add, change, or delete (string)
|
||||
"""
|
||||
ct = ContentType.objects.get_for_model(model)
|
||||
|
||||
# Get non proxied model
|
||||
concrete_model = model
|
||||
while concrete_model._meta.proxy_for_model:
|
||||
concrete_model = concrete_model._meta.proxy_for_model
|
||||
|
||||
return '{}.{}_{}'.format(
|
||||
ct.app_label,
|
||||
concrete_model._meta.app_label,
|
||||
action,
|
||||
ct.model
|
||||
concrete_model._meta.model_name
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user