diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-11-29 09:21:09 +0100 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-11-29 09:21:25 +0100 |
commit | f02c899e3ed0642148e3ff3121456dc28885fbfe (patch) | |
tree | 8367c4b796fa5fa697b732786e4ec658d93d5ce6 | |
parent | a241ce1bcd7e6f13b09fb4b2f3f44b7109a42760 (diff) |
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.
-rw-r--r-- | ogcp/views.py | 15 |
1 files 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 |