From af50b06082044fcbbf730deda985d0133ca98b88 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Tue, 14 Apr 2026 16:22:40 -0400 Subject: Switch collaboration permission checks to using User objects --- python/collaboration/project.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'python/collaboration/project.py') diff --git a/python/collaboration/project.py b/python/collaboration/project.py index a143e6d9..f78e488e 100644 --- a/python/collaboration/project.py +++ b/python/collaboration/project.py @@ -11,7 +11,7 @@ from ..binaryview import BinaryView, ProgressFuncType from ..database import Database from ..filemetadata import FileMetadata from ..project import Project -from . import databasesync, file, folder, permission, remote, util +from . import databasesync, file, folder, permission, remote, user, util def _nop(*args, **kwargs): @@ -713,35 +713,35 @@ class RemoteProject: if not core.BNRemoteProjectDeletePermission(self._handle, permission._handle): raise RuntimeError(util._last_error()) - def can_user_view(self, username: str) -> bool: + def can_user_view(self, user: user.User) -> bool: """ Determine if a user is in any of the view/edit/admin groups - :param username: Username of user to check - :return: True if they are in any of those groups + :param user: User to check + :return: True if the user has view permission (either directly or from a group) :raises: RuntimeError if there was an error """ - return core.BNRemoteProjectCanUserView(self._handle, username) + return core.BNRemoteProjectCanUserView(self._handle, user._handle) - def can_user_edit(self, username: str) -> bool: + def can_user_edit(self, user: user.User) -> bool: """ Determine if a user is in any of the edit/admin groups - :param username: Username of user to check - :return: True if they are in any of those groups + :param user: User to check + :return: True if the user has edit permission (either directly or from a group) :raises: RuntimeError if there was an error """ - return core.BNRemoteProjectCanUserEdit(self._handle, username) + return core.BNRemoteProjectCanUserEdit(self._handle, user._handle) - def can_user_admin(self, username: str) -> bool: + def can_user_admin(self, user: user.User) -> bool: """ Determine if a user is in the admin group - :param username: Username of user to check - :return: True if they are in any of those groups + :param user: User to check + :return: True if the user has admin permission (either directly or from a group) :raises: RuntimeError if there was an error """ - return core.BNRemoteProjectCanUserAdmin(self._handle, username) + return core.BNRemoteProjectCanUserAdmin(self._handle, user._handle) def upload_new_file( self, -- cgit v1.3.1