From 7c86ecf9a1280d6994527bfb970e45a9f181549a Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Thu, 25 Jan 2024 12:43:28 +0100 Subject: views: remove one level of indentation in action_image_restore r.status_code == requests.codes.ok is redundant, already checked for error, remove this check and save one level of indentation. --- ogcp/views.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index bf30e0f..f0049fc 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -783,25 +783,24 @@ def action_image_restore(): if r.status_code != requests.codes.ok: return ogserver_error('commands') - if r.status_code == requests.codes.ok: - partitions = r.json()['partitions'] - parts = [] - for partition in partitions: - disk_id = partition['disk'] - part_id = partition['partition'] - if part_id == 0: # This is the disk data, not a partition. - continue - part_code = partition['code'] - filesystem = partition['filesystem'] - - choice_value = (disk_id, part_id, part_code, filesystem) - parts.append(choice_value) - - if not part_choices: # Use first computer as reference part setup conf - part_choices = [part for part in parts] - elif part_choices != parts: - flash(_(f'Computers have different partition setup'), category='error') - return redirect(url_for('commands')) + partitions = r.json()['partitions'] + parts = [] + for partition in partitions: + disk_id = partition['disk'] + part_id = partition['partition'] + if part_id == 0: # This is the disk data, not a partition. + continue + part_code = partition['code'] + filesystem = partition['filesystem'] + + choice_value = (disk_id, part_id, part_code, filesystem) + parts.append(choice_value) + + if not part_choices: # Use first computer as reference part setup conf + part_choices = [part for part in parts] + elif part_choices != parts: + flash(_(f'Computers have different partition setup'), category='error') + return redirect(url_for('commands')) form.partition.choices = [ (f"{disk_id} {part_id}", -- cgit v1.2.3-18-g5258