Mercurial > kallithea
changeset 8947:abc29122c7f2 stable
repo group: introduce editing of owner
The repo group owner concept was only partially implemented. Owners were shown
in the repo group listing, but couldn't be changed. Users owning repo groups
couldn't be deleted, with no other solution than deleting owned repo groups.
This also fixes the existing broken update_repo_group API, which tried to use
unimplemented functionality.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 10 Dec 2022 18:18:05 +0100 |
parents | fdc9c2fd439a |
children | fd203abd0a81 |
files | kallithea/controllers/admin/repo_groups.py kallithea/model/forms.py kallithea/model/repo_group.py kallithea/templates/admin/repo_groups/repo_group_edit_settings.html kallithea/tests/api/api_base.py kallithea/tests/functional/test_admin_repo_groups.py |
diffstat | 6 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/admin/repo_groups.py Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/controllers/admin/repo_groups.py Sat Dec 10 18:18:05 2022 +0100 @@ -76,6 +76,7 @@ repo_group = db.RepoGroup.get_or_404(group_id) data = repo_group.get_dict() data['group_name'] = repo_group.name + data['owner'] = repo_group.owner.username # fill repository group users for p in repo_group.repo_group_to_perm: @@ -146,7 +147,7 @@ group_name=form_result['group_name'], group_description=form_result['group_description'], parent=form_result['parent_group_id'], - owner=request.authuser.user_id, # TODO: make editable + owner=request.authuser.user_id, copy_permissions=form_result['group_copy_permissions'] ) meta.Session().commit()
--- a/kallithea/model/forms.py Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/model/forms.py Sat Dec 10 18:18:05 2022 +0100 @@ -173,6 +173,7 @@ group_copy_permissions = v.StringBoolean(if_missing=False) if edit: + owner = All(v.UnicodeString(not_empty=True), v.ValidRepoUser()) # FIXME: do a special check that we cannot move a group to one of # its children pass
--- a/kallithea/model/repo_group.py Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/model/repo_group.py Sat Dec 10 18:18:05 2022 +0100 @@ -281,6 +281,8 @@ old_path = repo_group.full_path # change properties + if 'owner' in repo_group_args: + repo_group.owner = db.User.get_by_username(repo_group_args['owner']) if 'group_description' in repo_group_args: repo_group.group_description = repo_group_args['group_description'] if 'parent_group_id' in repo_group_args:
--- a/kallithea/templates/admin/repo_groups/repo_group_edit_settings.html Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/templates/admin/repo_groups/repo_group_edit_settings.html Sat Dec 10 18:18:05 2022 +0100 @@ -9,6 +9,13 @@ </div> <div class="form-group"> + <label class="control-label" for="owner">${_('Owner')}:</label> + <div> + ${h.text('owner',class_='form-control', placeholder=_('Type name of user'))} + </div> + </div> + + <div class="form-group"> <label class="control-label" for="group_description">${_('Description')}:</label> <div> ${h.textarea('group_description',cols=23,rows=5,class_='form-control')} @@ -47,5 +54,6 @@ $("#parent_group_id").select2({ 'dropdownAutoWidth': true }); + SimpleUserAutoComplete($('#owner')); }); </script>
--- a/kallithea/tests/api/api_base.py Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/tests/api/api_base.py Sat Dec 10 18:18:05 2022 +0100 @@ -1851,7 +1851,7 @@ self._compare_error(id_, expected, given=response.body) @base.parametrize('changing_attr,updates', [ - #('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), # currently broken + ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), ('description', {'description': 'new description'}), ('group_name', {'group_name': 'new_repo_name'}), ('parent', {'parent': 'test_group_for_update'}),
--- a/kallithea/tests/functional/test_admin_repo_groups.py Sat Dec 10 18:08:12 2022 +0100 +++ b/kallithea/tests/functional/test_admin_repo_groups.py Sat Dec 10 18:18:05 2022 +0100 @@ -53,6 +53,7 @@ # edit response = self.app.post(base.url('update_repos_group', group_name=group_name), {'group_name': group_name, + 'owner': base.TEST_USER_REGULAR2_LOGIN, 'group_description': 'lolo', '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'Updated repository group %s' % group_name)