mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +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 %}
|
{% block content %}
|
||||||
<h2>{{ title }}</h2>
|
<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">
|
<table class="table table-bordered table-condensed table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
@ -33,22 +33,23 @@
|
|||||||
<th>{% trans "Description" %}</th>
|
<th>{% trans "Description" %}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
{% for snapshot in snapshot_list %}
|
||||||
<td>{{ snapshot.number }}</td>
|
{% if not snapshot.is_default %}
|
||||||
<td>{{ snapshot.date }}</td>
|
<tr>
|
||||||
<td>{{ snapshot.description }}</td>
|
<td>{{ snapshot.number }}</td>
|
||||||
</tr>
|
<td>{{ snapshot.date }}</td>
|
||||||
|
<td>{{ snapshot.description }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<input type="submit" class="btn btn-danger" name="delete_confirm"
|
||||||
<input type="submit" class="btn btn-danger"
|
value="{% trans 'Delete Snapshots' %}"/>
|
||||||
value="{% blocktrans trimmed with number=snapshot.number %}
|
|
||||||
Delete Snapshot #{{ number }}
|
|
||||||
{% endblocktrans %}"/>
|
|
||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -23,27 +23,19 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% block configuration %}
|
{% block configuration %}
|
||||||
|
<form class="form" method="post">
|
||||||
<div class="button-table">
|
<div class="button-table">
|
||||||
|
|
||||||
<div class="button-row row">
|
<div class="button-row row">
|
||||||
<form class="form" method="post">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="col-xs-6 text-left">
|
<div class="col-xs-6 text-left">
|
||||||
<input type="submit" class="btn btn-primary" name="create"
|
<input type="submit" class="btn btn-primary" name="create"
|
||||||
value="{% trans 'Create Snapshot' %}"/>
|
value="{% trans 'Create Snapshot' %}"/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
<div class="col-xs-6 text-right">
|
||||||
<div class="col-xs-6 text-right">
|
<input type="submit" class="btn btn-primary" name="delete_selected"
|
||||||
<a title="{% trans 'Delete all the snapshots' %}"
|
value="{% trans 'Delete Snapshots' %}"/>
|
||||||
role="button" class="btn btn-danger"
|
</div>
|
||||||
{% if not has_deletable_snapshots %}
|
|
||||||
disabled="disabled"
|
|
||||||
{% else %}
|
|
||||||
href="{% url 'snapshot:delete-all' %}"
|
|
||||||
{% endif %}>
|
|
||||||
{% trans 'Delete All' %}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="table table-bordered table-condensed table-striped">
|
<table class="table table-bordered table-condensed table-striped">
|
||||||
@ -80,14 +72,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not snapshot.is_default %}
|
{% if not snapshot.is_default %}
|
||||||
<a href="{% url 'snapshot:delete' snapshot.number %}"
|
<input type="checkbox" name="snapshot_list" value={{ 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>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -95,7 +80,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -25,8 +25,8 @@ from . import views
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^sys/snapshot/$', views.index, name='index'),
|
url(r'^sys/snapshot/$', views.index, name='index'),
|
||||||
url(r'^sys/snapshot/manage/$', views.manage, name='manage'),
|
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/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,
|
url(r'^sys/snapshot/(?P<number>\d+)/rollback$', views.rollback,
|
||||||
name='rollback'),
|
name='rollback'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -70,6 +70,10 @@ def manage(request):
|
|||||||
if 'create' in request.POST:
|
if 'create' in request.POST:
|
||||||
actions.superuser_run('snapshot', ['create'])
|
actions.superuser_run('snapshot', ['create'])
|
||||||
messages.success(request, _('Created snapshot.'))
|
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'])
|
output = actions.superuser_run('snapshot', ['list'])
|
||||||
snapshots = json.loads(output)
|
snapshots = json.loads(output)
|
||||||
@ -124,22 +128,26 @@ def update_configuration(request, old_status, new_status):
|
|||||||
exception.args[2]))
|
exception.args[2]))
|
||||||
|
|
||||||
|
|
||||||
def delete(request, number):
|
def delete_selected(request):
|
||||||
"""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'))
|
|
||||||
|
|
||||||
output = actions.superuser_run('snapshot', ['list'])
|
output = actions.superuser_run('snapshot', ['list'])
|
||||||
snapshots = json.loads(output)
|
snapshots = json.loads(output)
|
||||||
snapshot = next(s for s in snapshots if s['number'] == number)
|
|
||||||
|
|
||||||
return TemplateResponse(request, 'snapshot_delete.html', {
|
if request.method == 'POST':
|
||||||
'title': _('Delete Snapshot'),
|
if 'snapshots' in request.session:
|
||||||
'snapshot': snapshot
|
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):
|
def delete_all(request):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user