summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2024-01-15 11:02:43 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-01-15 11:10:37 +0100
commitbf90e91e2474504bd7e810393c8e5d542a938d48 (patch)
tree2e3e8d0ef174a40a0cd6cf5123be6fb1c977aa43
parent19e0517511c20ac04d335f1d544a6b3c06838edd (diff)
views: Fix bug in images view
Fix unusable image view when an image has a repo associated that no longer exists. Display image under "unknown" if there is no repo for it.
-rw-r--r--ogcp/views.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 1004aec..316f25c 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1711,10 +1711,13 @@ def get_images_grouped_by_repos():
repo_id=image['repo_id']
repo_data={}
if repo_id not in repos:
- repo_name = [repo['name'] for repo in all_repos
- if repo_id == repo['id']][0]
+ image_repo = [repo['name'] for repo in all_repos
+ if repo_id == repo['id']]
repos[repo_id] = {}
- repos[repo_id]['name'] = repo_name
+ if image_repo:
+ repos[repo_id]['name'] = image_repo[0]
+ else:
+ repos[repo_id]['name'] = 'unknown'
repos[repo_id]['images'] = [image]
else:
repos[repo_id]['images'].append(image)