From cae11fb04e68a7aaba6212967253517137454d1d Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 17 Jul 2024 10:14:18 +0200 Subject: views: list default oglive in Set ogLive form Show default oglive as "ogLive (live name)" as the last option int the Set ogLive form. The previous implementation defined the default oglive as the most used when the default one is defined by /oglive/list. --- ogcp/views.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 2c8f650..456b444 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -2170,16 +2170,17 @@ def action_oglive(): if r.status_code != requests.codes.ok: return ogserver_error('commands') - most_used_oglive = max(oglives_set, key=lambda l: len(oglives_set[l])) - available_oglives = [(oglive.get('directory'), oglive.get('directory')) - for oglive in r.json()['oglive'] - if oglive.get('directory') == most_used_oglive] - if not available_oglives: - available_oglives.append(('default', 'default')) - available_oglives.extend([(oglive.get('directory'), oglive.get('directory')) - for oglive in r.json()['oglive'] - if oglive.get('directory') != most_used_oglive]) - form.oglive.choices = list(available_oglives) + oglive_list = r.json()['oglive'] + + available_oglives = [] + for oglive in oglive_list: + available_oglives.append((oglive.get('directory'), oglive.get('directory'))) + + default_idx = int(r.json()['default']) + default_oglive_dir = oglive_list[default_idx].get('directory') + available_oglives.append(('default', f'ogLive ({default_oglive_dir})')) + + form.oglive.choices = available_oglives form.ok.render_kw = {'formaction': url_for('action_oglive')} scopes, clients = get_scopes(set(ips)) -- cgit v1.2.3-18-g5258