From 074ab4a73669c83261cab6b954d49b0b1e5cec49 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 12 Feb 2018 16:38:50 +0530 Subject: [PATCH] snapshot: Enable Delete All only with non-default snapshots Signed-off-by: Sunil Mohan Adapa --- plinth/modules/snapshot/templates/snapshot.html | 10 +++++----- plinth/modules/snapshot/views.py | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plinth/modules/snapshot/templates/snapshot.html b/plinth/modules/snapshot/templates/snapshot.html index 5de3fef4e..aa3222f81 100644 --- a/plinth/modules/snapshot/templates/snapshot.html +++ b/plinth/modules/snapshot/templates/snapshot.html @@ -40,11 +40,11 @@ diff --git a/plinth/modules/snapshot/views.py b/plinth/modules/snapshot/views.py index 0621e6d32..7129c0ef6 100644 --- a/plinth/modules/snapshot/views.py +++ b/plinth/modules/snapshot/views.py @@ -52,11 +52,15 @@ def index(request): output = actions.superuser_run('snapshot', ['list']) snapshots = json.loads(output) + has_deletable_snapshots = any( + [snapshot for snapshot in snapshots[1:] + if not snapshot['is_default']]) return TemplateResponse(request, 'snapshot.html', { 'title': snapshot_module.name, 'description': snapshot_module.description, 'snapshots': snapshots, + 'has_deletable_snapshots': has_deletable_snapshots, 'form': form })