mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
snapshot: Enable Delete All only with non-default snapshots
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
fe17a8e541
commit
074ab4a736
@ -40,11 +40,11 @@
|
|||||||
<div class="col-xs-6 text-right">
|
<div class="col-xs-6 text-right">
|
||||||
<a title="{% trans 'Delete all the snapshots' %}"
|
<a title="{% trans 'Delete all the snapshots' %}"
|
||||||
role="button" class="btn btn-danger"
|
role="button" class="btn btn-danger"
|
||||||
{% if snapshots|length == 1 %}
|
{% if not has_deletable_snapshots %}
|
||||||
disabled="disabled"
|
disabled="disabled"
|
||||||
{% else %}
|
{% else %}
|
||||||
href="{% url 'snapshot:delete-all' %}"
|
href="{% url 'snapshot:delete-all' %}"
|
||||||
{% endif %}>
|
{% endif %}>
|
||||||
{% trans 'Delete All' %}
|
{% trans 'Delete All' %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -52,11 +52,15 @@ def index(request):
|
|||||||
|
|
||||||
output = actions.superuser_run('snapshot', ['list'])
|
output = actions.superuser_run('snapshot', ['list'])
|
||||||
snapshots = json.loads(output)
|
snapshots = json.loads(output)
|
||||||
|
has_deletable_snapshots = any(
|
||||||
|
[snapshot for snapshot in snapshots[1:]
|
||||||
|
if not snapshot['is_default']])
|
||||||
|
|
||||||
return TemplateResponse(request, 'snapshot.html', {
|
return TemplateResponse(request, 'snapshot.html', {
|
||||||
'title': snapshot_module.name,
|
'title': snapshot_module.name,
|
||||||
'description': snapshot_module.description,
|
'description': snapshot_module.description,
|
||||||
'snapshots': snapshots,
|
'snapshots': snapshots,
|
||||||
|
'has_deletable_snapshots': has_deletable_snapshots,
|
||||||
'form': form
|
'form': form
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user