summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-08-06 09:24:44 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-08-06 09:24:44 +0200
commit8e16c319528972048247a903f7acace6c4eeefa9 (patch)
tree845c16dafba7c7efbc69a9f0029f5e87249e3e50 /ogcp
parent35cfb59f4c086e0a1470ac69d0b0c2ee6b2bd22e (diff)
views: sort images based on alphabetical name order
Show images in alphabetical order in every views listing images. The only exception is the dashboard as it shows them from newer to older.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 2a89d01..6b8607e 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -834,6 +834,12 @@ def get_images_from_repo(server, repo_id):
res.append(image)
return res
+def get_image_key(image):
+ return image['name']
+
+def sort_images(images):
+ images.sort(key=get_image_key, reverse=False)
+
def get_clients_repo(server, ips):
repo_id=None
for ip in ips:
@@ -984,6 +990,8 @@ def action_image_restore():
except ServerErrorCode:
return ogserver_error('commands')
+ sort_images(images)
+
for image in images:
form.image.choices.append((image['id'], image['name']))
@@ -2431,6 +2439,8 @@ def action_image_update():
except ServerErrorCode:
return ogserver_error('commands')
+ sort_images(images)
+
for image in images:
form.image.choices.append((image['id'], image['name']))
@@ -2891,6 +2901,9 @@ def get_images_grouped_by_repos():
except ServerErrorCode:
continue
repos={}
+
+ sort_images(images)
+
for image in images:
repo_id=image['repo_id']
repo_data={}