##// END OF EJS Templates
docs: added new admin trick to bulk change owner of repository
super-admin -
r4776:c2cdde73 default
parent child Browse files
Show More
@@ -262,3 +262,39 b' ishell interface should be used.'
262 262 In [1]: repo = Repository.get_by_repo_name('SOME_REPO_NAME')
263 263 In [2]: repo.archived = False
264 264 In [3]: Session().add(repo);Session().commit()
265
266
267
268
269 Bulk change repository owner
270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
271
272 Here's how one can change an owner of repository for an user who has been de activated.
273 Settings a new owner can be done via ishell for all repositories that past owner had.
274
275 do run this script the interactive ishell interface should be used.
276
277 .. code-block:: bash
278
279 # Open iShell from the terminal
280 $ rccontrol ishell enterprise-1/community-1
281
282
283 .. code-block:: python
284
285 from rhodecode.model.db import User, Repository, Session
286 from rhodecode.model.permission import PermissionModel
287
288 # replace old-owner and new-owner with your exact users
289 old_owner = User.get_by_username('old-owner')
290 new_owner = User.get_by_username('new-owner')
291
292 # list of users we need to "flush" permissions
293 affected_user_ids = [new_owner.user_id, old_owner.user_id]
294
295 for repo in Repository.get_all_repos(user_id=old_owner.user_id):
296 repo.user = new_owner
297 Session().add(repo)
298 Session().commit()
299
300 PermissionModel().trigger_permission_flush(affected_user_ids)
General Comments 0
You need to be logged in to leave comments. Login now