From 3b932fc6a884a3fda8b7a5fdddac85aef8e21a30 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Wed, 29 Nov 2023 12:27:19 +0100 Subject: views: fix repository list in update client Make the repository list's first element be the current repo in use. This is needed because, otherwise, an update could inadvertently change the repo. Remove a print statement that is no longer needed --- ogcp/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index 53487a1..fa458e3 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -897,7 +897,6 @@ def action_client_update(): db_client = r.json() form.server.data = "{0}:{1}".format(server.ip, server.port) - print("server ip:", form.server.data) form.ip.data = db_client['ip'] form.ip.render_kw = {'readonly': True} form.name.data = db_client['name'] @@ -907,7 +906,6 @@ def action_client_update(): form.remote.data = db_client['remote'] form.maintenance.data = db_client['maintenance'] form.netiface.data = db_client['netiface'] - form.repo.data = db_client['repo_id'] form.boot.render_kw = {'readonly': True} r = server.get('/scopes') @@ -919,7 +917,10 @@ def action_client_update(): form.room.render_kw = {'readonly': True} repositories = get_repositories(server) - form.repo.choices = [(repo["id"], repo["name"]) for repo in repositories] + form.repo.choices = [(repo["id"], repo["name"]) for repo in repositories + if db_client['repo_id'] == repo["id"]] + form.repo.choices.extend([(repo["id"], repo["name"]) for repo in repositories + if db_client['repo_id'] != repo["id"]]) form.create.render_kw = {"formaction": url_for('action_client_update')} return render_template('actions/client_details.html', form=form, -- cgit v1.2.3-18-g5258