Skip to content

Commit 6f4a3f1

Browse files
committed
Don't fetch the whole object when checking permissions
This also checks for is_superuser first Kind of related to readthedocs#5460
1 parent 173c1f8 commit 6f4a3f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

readthedocs/core/permissions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class AdminPermissionBase:
99

1010
@classmethod
1111
def is_admin(cls, user, project):
12-
return user in project.users.all() or user.is_superuser
12+
return user.is_superuser or project.users.filter(pk=user.pk).exists()
1313

1414
@classmethod
1515
def is_member(cls, user, obj):
16-
return user in obj.users.all() or user.is_superuser
16+
return user.is_superuser or obj.users.filter(pk=user.pk).exists()
1717

1818

1919
class AdminPermission(SettingsOverrideObject):

0 commit comments

Comments
 (0)