From 906c3070edd8973df823f60ea935f1985625c8d6 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Tue, 19 Dec 2023 13:15:09 +0100 Subject: views: Fix bug in client detail with non existing images Fix client detail form failing in some cases. It would fail if the user wanted to view the details of a client, that had a partition using an image that is no longer in the list of all images stored by the servers. This could happen if the image was deleted, but the client still was using the image in one of its partitions --- ogcp/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 7345700..766db70 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -888,8 +888,11 @@ def action_client_info(): for entry in setup: if images and entry['image'] != 0: - image = next(img for img in images if img['id'] == entry['image']) - entry['image'] = image['name'] + image = next((img for img in images if img['id'] == entry['image']), None) + if image: + entry['image'] = image['name'] + else: + entry['image'] = "" else: entry['image'] = "" -- cgit v1.2.3-18-g5258