docs: added new admin trick to bulk change owner of repository
This commit is contained in:
parent
063cb9f16b
commit
127da865d6
1 changed files with 36 additions and 0 deletions
|
|
@ -262,3 +262,39 @@ ishell interface should be used.
|
|||
In [1]: repo = Repository.get_by_repo_name('SOME_REPO_NAME')
|
||||
In [2]: repo.archived = False
|
||||
In [3]: Session().add(repo);Session().commit()
|
||||
|
||||
|
||||
|
||||
|
||||
Bulk change repository owner
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Here's how one can change an owner of repository for an user who has been de activated.
|
||||
Settings a new owner can be done via ishell for all repositories that past owner had.
|
||||
|
||||
do run this script the interactive ishell interface should be used.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Open iShell from the terminal
|
||||
$ rccontrol ishell enterprise-1/community-1
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from rhodecode.model.db import User, Repository, Session
|
||||
from rhodecode.model.permission import PermissionModel
|
||||
|
||||
# replace old-owner and new-owner with your exact users
|
||||
old_owner = User.get_by_username('old-owner')
|
||||
new_owner = User.get_by_username('new-owner')
|
||||
|
||||
# list of users we need to "flush" permissions
|
||||
affected_user_ids = [new_owner.user_id, old_owner.user_id]
|
||||
|
||||
for repo in Repository.get_all_repos(user_id=old_owner.user_id):
|
||||
repo.user = new_owner
|
||||
Session().add(repo)
|
||||
Session().commit()
|
||||
|
||||
PermissionModel().trigger_permission_flush(affected_user_ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue