##// END OF EJS Templates
users: replaced extraction of user_ids with more efficient method....
dan -
r4190:d89af9cb stable
parent child Browse files
Show More
@@ -101,7 +101,7 b' class RepoGroupPermissionsView(RepoGroup'
101 affected_user_ids = None
101 affected_user_ids = None
102 if changes.get('default_user_changed', False):
102 if changes.get('default_user_changed', False):
103 # if we change the default user, we need to flush everyone permissions
103 # if we change the default user, we need to flush everyone permissions
104 affected_user_ids = [x.user_id for x in User.get_all()]
104 affected_user_ids = User.get_all_user_ids()
105 PermissionModel().flush_user_permission_caches(
105 PermissionModel().flush_user_permission_caches(
106 changes, affected_user_ids=affected_user_ids)
106 changes, affected_user_ids=affected_user_ids)
107
107
@@ -94,7 +94,7 b' class RepoSettingsPermissionsView(RepoAp'
94 affected_user_ids = None
94 affected_user_ids = None
95 if changes.get('default_user_changed', False):
95 if changes.get('default_user_changed', False):
96 # if we change the default user, we need to flush everyone permissions
96 # if we change the default user, we need to flush everyone permissions
97 affected_user_ids = [x.user_id for x in User.get_all()]
97 affected_user_ids = User.get_all_user_ids()
98 PermissionModel().flush_user_permission_caches(
98 PermissionModel().flush_user_permission_caches(
99 changes, affected_user_ids=affected_user_ids)
99 changes, affected_user_ids=affected_user_ids)
100
100
@@ -126,7 +126,7 b' class RepoSettingsPermissionsView(RepoAp'
126 self.db_repo_name), category='error')
126 self.db_repo_name), category='error')
127
127
128 # NOTE(dan): we change repo private mode we need to notify all USERS
128 # NOTE(dan): we change repo private mode we need to notify all USERS
129 affected_user_ids = [x.user_id for x in User.get_all()]
129 affected_user_ids = User.get_all_user_ids()
130 PermissionModel().trigger_permission_flush(affected_user_ids)
130 PermissionModel().trigger_permission_flush(affected_user_ids)
131
131
132 return {
132 return {
@@ -1025,6 +1025,17 b' class User(Base, BaseModel):'
1025 return qry.all()
1025 return qry.all()
1026
1026
1027 @classmethod
1027 @classmethod
1028 def get_all_user_ids(cls, only_active=True):
1029 """
1030 Returns all users IDs
1031 """
1032 qry = Session().query(User.user_id)
1033
1034 if only_active:
1035 qry = qry.filter(User.active == true())
1036 return [x.user_id for x in qry]
1037
1038 @classmethod
1028 def get_default_user(cls, cache=False, refresh=False):
1039 def get_default_user(cls, cache=False, refresh=False):
1029 user = User.get_by_username(User.DEFAULT_USER, cache=cache)
1040 user = User.get_by_username(User.DEFAULT_USER, cache=cache)
1030 if user is None:
1041 if user is None:
General Comments 0
You need to be logged in to leave comments. Login now