From f02c899e3ed0642148e3ff3121456dc28885fbfe Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 29 Nov 2024 09:21:09 +0100 Subject: views: select default live when it is the most used live Select the default live entry instead of the entry of the live that corresponds to the default live in the "Set ogLive" view. --- ogcp/views.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index a597f75..5d08f28 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -2510,13 +2510,7 @@ def action_oglive(): return ogserver_error('commands') oglive_list = r.json()['oglive'] - most_used_live = max(oglives_set, key=lambda l: len(oglives_set[l])) - default_idx = int(r.json()['default']) - default_oglive_dir = oglive_list[default_idx].get('directory') - - if most_used_live == OG_CLIENT_DEFAULT_LIVEDIR: - most_used_live = default_oglive_dir available_oglives = [] for oglive in oglive_list: @@ -2526,7 +2520,14 @@ def action_oglive(): else: available_oglives.append(live_entry) - available_oglives.append(('default', f'ogLive ({default_oglive_dir})')) + default_idx = int(r.json()['default']) + default_oglive_dir = oglive_list[default_idx].get('directory') + default_live_entry = ('default', f'ogLive ({default_oglive_dir})') + + if most_used_live == OG_CLIENT_DEFAULT_LIVEDIR: + available_oglives.insert(0, default_live_entry) + else: + available_oglives.append(default_live_entry) form.oglive.choices = available_oglives -- cgit v1.2.3-18-g5258