From a9d367e795a00358c8c34e205ee17beddbcd00dd Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Fri, 15 Dec 2023 11:35:30 +0100 Subject: views: Preselect client's associated repo Make the create-image menu preselect the repo of the selected client --- ogcp/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ogcp/views.py b/ogcp/views.py index 406de44..8494d4f 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1233,9 +1233,14 @@ def action_image_create(): f"| {PART_TYPE_CODES[part.get('code')]} " f"{FS_CODES[part.get('filesystem')]}") ) + r = server.get('/client/info', payload={'client': list(ips)}) + client_repo_id = r.json()['repo_id'] repositories = get_repositories(server) + form.repository.choices = [ (repo['id'], repo['name']) for repo in repositories + if client_repo_id == repo['id']] for repo in repositories: - form.repository.choices.append((repo['id'], repo['name'])) + if client_repo_id != repo['id']: + form.repository.choices.append((repo['id'], repo['name'])) scopes, clients = get_scopes(set(ips)) return render_template('actions/image_create.html', form=form, -- cgit v1.2.3-18-g5258