summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-06 11:11:08 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-06-07 14:35:41 +0200
commite136e77b56edbf730cad36a404cd2f9fadb0fdeb (patch)
tree8dd3879c5099e1e0d336f36cca32fc39859e0562 /ogcp
parenteb1b1c4cdfd26210115f1dc4ce5f0e8c99fe5711 (diff)
views: show human readable boot modes
Add better visualization to the boot modes shown in /action/mode. Use a dictinary to implement hardcoded human readble strings of the form choices. A better method will be implemented in the future.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 6a0d99c..41042a8 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1757,11 +1757,21 @@ def action_mode():
if r.status_code != requests.codes.ok:
return ogserver_error('commands')
+ mode_descriptions = {
+ 'pxe': 'ogLive (pxe)',
+ '11': 'Disk 1 Partition 1 (11)',
+ '19pxeADMIN': 'ogLive Debug (19pxeADMIN)',
+ '12': 'Disk 1 Partition 2 (12)',
+ '13': 'Disk 1 Partition 3 (13)',
+ 'memtest': 'Memory Test (memtest)',
+ }
+
most_used_mode = max(modes_set, key=lambda m: len(modes_set[m]))
available_modes = []
if most_used_mode in r.json()['modes']:
- available_modes.append((most_used_mode, most_used_mode))
- available_modes.extend([(mode, mode) for mode in r.json()['modes'] if mode != most_used_mode])
+ most_used_t = (most_used_mode, mode_descriptions.get(most_used_mode, most_used_mode))
+ available_modes.append(most_used_t)
+ available_modes.extend([(mode, mode_descriptions.get(mode, mode)) for mode in r.json()['modes'] if mode != most_used_mode])
if not available_modes:
flash(_('no boot templates are available in the server'),
category='error')