From bf90e91e2474504bd7e810393c8e5d542a938d48 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Mon, 15 Jan 2024 11:02:43 +0100 Subject: 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. --- ogcp/views.py | 9 ++++++--- 1 file 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) -- cgit v1.2.3-18-g5258