confirm before restoring changes
This commit is contained in:
parent
609fb88c72
commit
259f7a14b9
2 changed files with 21 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% include 'editor/fragment_modal_close.html' %}
|
||||||
|
<h3>{% trans 'Restore original state' %}</h3>
|
||||||
|
<form action="{{ request.path }}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p>{% trans 'Do you really want to restore the original state before this change?' %}</p>
|
||||||
|
<input type="hidden" name="restore" value="{{ pk }}">
|
||||||
|
{% buttons %}
|
||||||
|
<button class="invisiblesubmit" type="submit"></button>
|
||||||
|
<a class="btn btn-default" href="{{ request.path }}">
|
||||||
|
{% trans 'Cancel' %}
|
||||||
|
</a>
|
||||||
|
<button type="submit" name="restore_confirm" value="1" class="btn btn-primary pull-right">
|
||||||
|
{% trans 'Restore' %}
|
||||||
|
</button>
|
||||||
|
{% endbuttons %}
|
||||||
|
</form>
|
|
@ -29,6 +29,8 @@ def changeset_detail(request, pk, show_history=False):
|
||||||
if restore.isdigit():
|
if restore.isdigit():
|
||||||
change = changeset.changes.filter(pk=restore).first()
|
change = changeset.changes.filter(pk=restore).first()
|
||||||
if change is not None and change.can_restore:
|
if change is not None and change.can_restore:
|
||||||
|
if request.POST.get('restore_confirm') != '1':
|
||||||
|
return render(request, 'editor/changeset_restore_confirm.html', {'pk': change.pk})
|
||||||
change.restore(request.user if request.user.is_authenticated else None)
|
change.restore(request.user if request.user.is_authenticated else None)
|
||||||
messages.success(request, _('Original state has been restored!'))
|
messages.success(request, _('Original state has been restored!'))
|
||||||
return redirect(request.path)
|
return redirect(request.path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue