mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-19 20:41:56 +00:00
Show confirmation message before delete
This commit is contained in:
parent
616e8ea1e7
commit
b7a500d577
2 changed files with 34 additions and 4 deletions
|
|
@ -0,0 +1,19 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% blocktrans with title=page.title %}Delete {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block bodyclass %}menu-explorer{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Delete" as del_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=del_str subtitle=page.title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<p>
|
||||
{% trans 'Are you sure you want to delete this form submission?' %}
|
||||
</p>
|
||||
<form action="{% url 'wagtailforms_delete_submission' page.id submission.id %}" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="submit" value="{% trans 'Delete it' %}" class="serious">
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -7,11 +7,11 @@ from django.core.exceptions import PermissionDenied
|
|||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404, render, redirect
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailforms.models import FormSubmission, get_forms_for_user
|
||||
from wagtail.wagtailforms.forms import SelectDateForm
|
||||
|
||||
from wagtail.wagtailadmin import messages
|
||||
|
||||
def index(request):
|
||||
p = request.GET.get("p", 1)
|
||||
|
|
@ -34,9 +34,20 @@ def index(request):
|
|||
def delete_submission(request, page_id, submission_id):
|
||||
if not get_forms_for_user(request.user).filter(id=page_id).exists():
|
||||
raise PermissionDenied
|
||||
FormSubmission.objects.get(id=submission_id).delete()
|
||||
|
||||
return redirect('wagtailforms_list_submissions', page_id)
|
||||
submission = get_object_or_404(FormSubmission, id=submission_id)
|
||||
page = get_object_or_404(Page, id=page_id)
|
||||
|
||||
if request.method == 'POST':
|
||||
submission.delete()
|
||||
|
||||
messages.success(request, _("Submission deleted."))
|
||||
return redirect('wagtailforms_list_submissions', page_id)
|
||||
|
||||
return render(request, 'wagtailforms/confirm_delete.html', {
|
||||
'page': page,
|
||||
'submission': submission
|
||||
})
|
||||
|
||||
def list_submissions(request, page_id):
|
||||
form_page = get_object_or_404(Page, id=page_id).specific
|
||||
|
|
|
|||
Loading…
Reference in a new issue