diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-07-17 10:14:18 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-07-17 10:32:56 +0200 |
commit | cae11fb04e68a7aaba6212967253517137454d1d (patch) | |
tree | 15caa37fc666fd7a3c81d3e115bcafc99516b92a /ogcp | |
parent | 314a173b6cc3125190786e43158b7a60063f33bf (diff) |
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.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/views.py | 21 |
1 files 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)) |