diff --git a/plinth/modules/snapshot/templates/snapshot_delete_all.html b/plinth/modules/snapshot/templates/snapshot_delete_all.html
deleted file mode 100644
index 2e7e7f23b..000000000
--- a/plinth/modules/snapshot/templates/snapshot_delete_all.html
+++ /dev/null
@@ -1,57 +0,0 @@
-{% extends "base.html" %}
-{% comment %}
-#
-# This file is part of FreedomBox.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-{% endcomment %}
-
-{% load bootstrap %}
-{% load i18n %}
-
-{% block content %}
-
{{ title }}
-
- {% trans "Delete the following snapshots permanently?" %}
-
-
-
- {% trans "Number" %}
- {% trans "Date" %}
- {% trans "Description" %}
-
-
- {% for snapshot in snapshots %}
- {% if not snapshot.is_default %}
-
- {{ snapshot.number }}
- {{ snapshot.date }}
- {{ snapshot.description }}
-
- {% endif %}
- {% endfor %}
-
-
-
-
-
-
-
-{% endblock %}
diff --git a/plinth/modules/snapshot/templates/snapshot_delete_selected.html b/plinth/modules/snapshot/templates/snapshot_delete_selected.html
index dd95e05ef..d6e045552 100644
--- a/plinth/modules/snapshot/templates/snapshot_delete_selected.html
+++ b/plinth/modules/snapshot/templates/snapshot_delete_selected.html
@@ -33,7 +33,7 @@
{% trans "Description" %}
- {% for snapshot in snapshot_list %}
+ {% for snapshot in snapshots %}
{% if not snapshot.is_default %}
{{ snapshot.number }}
diff --git a/plinth/modules/snapshot/templates/snapshot_manage.html b/plinth/modules/snapshot/templates/snapshot_manage.html
index c1272c82a..a5ee28f21 100644
--- a/plinth/modules/snapshot/templates/snapshot_manage.html
+++ b/plinth/modules/snapshot/templates/snapshot_manage.html
@@ -33,7 +33,7 @@
value="{% trans 'Create Snapshot' %}"/>
-
@@ -44,7 +44,7 @@
{% trans "Date" %}
{% trans "Description" %}
{% trans "Rollback" %}
- {% trans "Delete" %}
+
{% for snapshot in snapshots %}
@@ -81,6 +81,19 @@
-
- {% endblock %}
+
{% endblock %}
+{% endblock %}
+
+{% block page_js %}
+
+{% endblock %}
+
diff --git a/plinth/modules/snapshot/urls.py b/plinth/modules/snapshot/urls.py
index 66f49c95e..f3b3aa324 100644
--- a/plinth/modules/snapshot/urls.py
+++ b/plinth/modules/snapshot/urls.py
@@ -25,7 +25,6 @@ from . import views
urlpatterns = [
url(r'^sys/snapshot/$', views.index, name='index'),
url(r'^sys/snapshot/manage/$', views.manage, name='manage'),
- url(r'^sys/snapshot/all/delete$', views.delete_all, name='delete-all'),
url(r'^sys/snapshot/selected/delete$', views.delete_selected, name='delete-selected'),
url(r'^sys/snapshot/(?P\d+)/rollback$', views.rollback,
name='rollback'),
diff --git a/plinth/modules/snapshot/views.py b/plinth/modules/snapshot/views.py
index 7393efaa6..71006007e 100644
--- a/plinth/modules/snapshot/views.py
+++ b/plinth/modules/snapshot/views.py
@@ -71,9 +71,10 @@ def manage(request):
actions.superuser_run('snapshot', ['create'])
messages.success(request, _('Created snapshot.'))
if 'delete_selected' in request.POST:
- snapshot_to_delete = request.POST.getlist('snapshot_list')
- request.session['snapshots'] = snapshot_to_delete
- return redirect(reverse('snapshot:delete-selected'))
+ if request.POST.getlist('snapshot_list'):
+ snapshot_to_delete = request.POST.getlist('snapshot_list')
+ request.session['snapshots'] = snapshot_to_delete
+ return redirect(reverse('snapshot:delete-selected'))
output = actions.superuser_run('snapshot', ['list'])
snapshots = json.loads(output)
@@ -135,37 +136,25 @@ def delete_selected(request):
if request.method == 'POST':
if 'snapshots' in request.session:
to_delete = request.session['snapshots']
- for snapshot in to_delete:
- actions.superuser_run('snapshot', ['delete', snapshot])
- messages.success(request, _('Deleted the selected snapshots'))
+ if to_delete == len(snapshots):
+ actions.superuser_run('snapshot', ['delete_all'])
+ messages.success(request, _('Deleted all snapshots'))
+ else:
+ for snapshot in to_delete:
+ actions.superuser_run('snapshot', ['delete', snapshot])
+ messages.success(request, _('Deleted selected snapshots'))
return redirect(reverse('snapshot:manage'))
if 'snapshots' in request.session:
data = request.session['snapshots']
to_delete = list(filter(lambda x: x['number'] in data, snapshots))
- return TemplateResponse(request, 'snapshot_delete_all.html', {
+ return TemplateResponse(request, 'snapshot_delete_selected.html', {
'title': _('Delete Snapshots'),
'snapshots': to_delete
})
-def delete_all(request):
- """Show confirmation to delete all snapshots."""
- if request.method == 'POST':
- actions.superuser_run('snapshot', ['delete-all'])
- messages.success(request, _('Deleted all snapshots.'))
- return redirect(reverse('snapshot:manage'))
-
- output = actions.superuser_run('snapshot', ['list'])
- snapshots = json.loads(output)
-
- return TemplateResponse(request, 'snapshot_delete_all.html', {
- 'title': _('Delete Snapshots'),
- 'snapshots': snapshots[1:]
- })
-
-
def rollback(request, number):
"""Show confirmation to rollback to a snapshot."""
if request.method == 'POST':