mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
Changes delete all to delete selected in snapshot
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
aa0dcbe76c
commit
5ec14f7c97
@ -24,7 +24,7 @@
|
||||
{% block content %}
|
||||
<h2>{{ title }}</h2>
|
||||
|
||||
<p>{% trans "Delete this snapshot permanently?" %}</p>
|
||||
<p>{% trans "Delete the following snapshots permanently?" %}</p>
|
||||
|
||||
<table class="table table-bordered table-condensed table-striped">
|
||||
<thead>
|
||||
@ -33,22 +33,23 @@
|
||||
<th>{% trans "Description" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ snapshot.number }}</td>
|
||||
<td>{{ snapshot.date }}</td>
|
||||
<td>{{ snapshot.description }}</td>
|
||||
</tr>
|
||||
{% for snapshot in snapshot_list %}
|
||||
{% if not snapshot.is_default %}
|
||||
<tr>
|
||||
<td>{{ snapshot.number }}</td>
|
||||
<td>{{ snapshot.date }}</td>
|
||||
<td>{{ snapshot.description }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="submit" class="btn btn-danger"
|
||||
value="{% blocktrans trimmed with number=snapshot.number %}
|
||||
Delete Snapshot #{{ number }}
|
||||
{% endblocktrans %}"/>
|
||||
<input type="submit" class="btn btn-danger" name="delete_confirm"
|
||||
value="{% trans 'Delete Snapshots' %}"/>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
@ -23,27 +23,19 @@
|
||||
|
||||
{% block content %}
|
||||
{% block configuration %}
|
||||
<form class="form" method="post">
|
||||
<div class="button-table">
|
||||
|
||||
<div class="button-row row">
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="col-xs-6 text-left">
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="{% trans 'Create Snapshot' %}"/>
|
||||
</div>
|
||||
</form>
|
||||
<div class="col-xs-6 text-right">
|
||||
<a title="{% trans 'Delete all the snapshots' %}"
|
||||
role="button" class="btn btn-danger"
|
||||
{% if not has_deletable_snapshots %}
|
||||
disabled="disabled"
|
||||
{% else %}
|
||||
href="{% url 'snapshot:delete-all' %}"
|
||||
{% endif %}>
|
||||
{% trans 'Delete All' %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<input type="submit" class="btn btn-primary" name="delete_selected"
|
||||
value="{% trans 'Delete Snapshots' %}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered table-condensed table-striped">
|
||||
@ -80,14 +72,7 @@
|
||||
</td>
|
||||
<td>
|
||||
{% if not snapshot.is_default %}
|
||||
<a href="{% url 'snapshot:delete' snapshot.number %}"
|
||||
class="btn btn-default btn-sm" role="button"
|
||||
title="{% blocktrans trimmed with number=snapshot.number %}
|
||||
Delete snapshot #{{ number }}
|
||||
{% endblocktrans %}">
|
||||
<span class="glyphicon glyphicon-trash"
|
||||
aria-hidden="true"></span>
|
||||
</a>
|
||||
<input type="checkbox" name="snapshot_list" value={{ snapshot.number }} />
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
@ -95,7 +80,7 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@ -25,8 +25,8 @@ 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/(?P<number>\d+)/delete$', views.delete, name='delete'),
|
||||
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<number>\d+)/rollback$', views.rollback,
|
||||
name='rollback'),
|
||||
]
|
||||
|
||||
@ -70,6 +70,10 @@ def manage(request):
|
||||
if 'create' in request.POST:
|
||||
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'))
|
||||
|
||||
output = actions.superuser_run('snapshot', ['list'])
|
||||
snapshots = json.loads(output)
|
||||
@ -124,22 +128,26 @@ def update_configuration(request, old_status, new_status):
|
||||
exception.args[2]))
|
||||
|
||||
|
||||
def delete(request, number):
|
||||
"""Show confirmation to delete a snapshot."""
|
||||
if request.method == 'POST':
|
||||
actions.superuser_run('snapshot', ['delete', number])
|
||||
messages.success(
|
||||
request, _('Deleted snapshot #{number}.').format(number=number))
|
||||
return redirect(reverse('snapshot:manage'))
|
||||
|
||||
def delete_selected(request):
|
||||
output = actions.superuser_run('snapshot', ['list'])
|
||||
snapshots = json.loads(output)
|
||||
snapshot = next(s for s in snapshots if s['number'] == number)
|
||||
|
||||
return TemplateResponse(request, 'snapshot_delete.html', {
|
||||
'title': _('Delete Snapshot'),
|
||||
'snapshot': snapshot
|
||||
})
|
||||
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'))
|
||||
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', {
|
||||
'title': _('Delete Snapshots'),
|
||||
'snapshots': to_delete
|
||||
})
|
||||
|
||||
|
||||
def delete_all(request):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user