diff --git a/rhodecode/apps/repo_group/views/repo_group_permissions.py b/rhodecode/apps/repo_group/views/repo_group_permissions.py --- a/rhodecode/apps/repo_group/views/repo_group_permissions.py +++ b/rhodecode/apps/repo_group/views/repo_group_permissions.py @@ -101,7 +101,7 @@ class RepoGroupPermissionsView(RepoGroup affected_user_ids = None if changes.get('default_user_changed', False): # if we change the default user, we need to flush everyone permissions - affected_user_ids = [x.user_id for x in User.get_all()] + affected_user_ids = User.get_all_user_ids() PermissionModel().flush_user_permission_caches( changes, affected_user_ids=affected_user_ids) diff --git a/rhodecode/apps/repository/views/repo_permissions.py b/rhodecode/apps/repository/views/repo_permissions.py --- a/rhodecode/apps/repository/views/repo_permissions.py +++ b/rhodecode/apps/repository/views/repo_permissions.py @@ -94,7 +94,7 @@ class RepoSettingsPermissionsView(RepoAp affected_user_ids = None if changes.get('default_user_changed', False): # if we change the default user, we need to flush everyone permissions - affected_user_ids = [x.user_id for x in User.get_all()] + affected_user_ids = User.get_all_user_ids() PermissionModel().flush_user_permission_caches( changes, affected_user_ids=affected_user_ids) @@ -126,7 +126,7 @@ class RepoSettingsPermissionsView(RepoAp self.db_repo_name), category='error') # NOTE(dan): we change repo private mode we need to notify all USERS - affected_user_ids = [x.user_id for x in User.get_all()] + affected_user_ids = User.get_all_user_ids() PermissionModel().trigger_permission_flush(affected_user_ids) return { diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1025,6 +1025,17 @@ class User(Base, BaseModel): return qry.all() @classmethod + def get_all_user_ids(cls, only_active=True): + """ + Returns all users IDs + """ + qry = Session().query(User.user_id) + + if only_active: + qry = qry.filter(User.active == true()) + return [x.user_id for x in qry] + + @classmethod def get_default_user(cls, cache=False, refresh=False): user = User.get_by_username(User.DEFAULT_USER, cache=cache) if user is None: