mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
12589 move user and group admin from admin (#12877)
Move admin views for users, groups, and object permissions from the admin site to the NetBox frontend --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from django.db.models import Prefetch, QuerySet
|
||||
|
||||
from users.constants import CONSTRAINT_TOKEN_USER
|
||||
from utilities.permissions import permission_is_exempt, qs_filter_from_constraints
|
||||
from utilities.permissions import get_permission_for_model, permission_is_exempt, qs_filter_from_constraints
|
||||
|
||||
__all__ = (
|
||||
'RestrictedPrefetch',
|
||||
@ -46,9 +46,7 @@ class RestrictedQuerySet(QuerySet):
|
||||
:param action: The action which must be permitted (e.g. "view" for "dcim.view_site"); default is 'view'
|
||||
"""
|
||||
# Resolve the full name of the required permission
|
||||
app_label = self.model._meta.app_label
|
||||
model_name = self.model._meta.model_name
|
||||
permission_required = f'{app_label}.{action}_{model_name}'
|
||||
permission_required = get_permission_for_model(self.model, action)
|
||||
|
||||
# Bypass restriction for superusers and exempt views
|
||||
if user.is_superuser or permission_is_exempt(permission_required):
|
||||
|
Reference in New Issue
Block a user