From f8149f4fdeeea8d634a6a360185a98f035bbd082 Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Thu, 15 Jan 2026 23:07:02 +0100 Subject: [PATCH] fix(users): Refactor object permission query logic Simplifies the `OBJECTPERMISSION_OBJECT_TYPES` definition by adjusting query filters and introducing new conditions for specific app labels and models. Fixes #21051 --- netbox/users/constants.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netbox/users/constants.py b/netbox/users/constants.py index dbb01df22..0888d16bc 100644 --- a/netbox/users/constants.py +++ b/netbox/users/constants.py @@ -3,9 +3,10 @@ import string from django.db.models import Q -OBJECTPERMISSION_OBJECT_TYPES = Q( - ~Q(app_label__in=['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users']) | - Q(app_label='users', model__in=['objectpermission', 'token', 'group', 'user', 'owner']) +OBJECTPERMISSION_OBJECT_TYPES = ( + (Q(public=True) & ~Q(app_label='core', model='objecttype')) + | Q(app_label='core', model__in=['managedfile']) + | Q(app_label='extras', model__in=['scriptmodule', 'taggeditem']) ) CONSTRAINT_TOKEN_USER = '$user'