From e34c46f9aaf2fec6f1525aac4f00043e2a5659a6 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 27 Sep 2013 17:54:05 +0200 Subject: [PATCH] Fixed snippet delete function. --- dpaste/templates/dpaste/about.html | 2 +- dpaste/views.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index 1f328f4..f1d6efd 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -63,7 +63,7 @@

Type the 5 letter code of your snippet in the field and submit. - Like this yellow one here: http://dpaste.de/SiZrT/ + Like this yellow one here: http://dpaste.de/SiZrT

diff --git a/dpaste/views.py b/dpaste/views.py index 0472770..8b9e61a 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -104,13 +104,16 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h return response -def snippet_delete(request, snippet_id): +def snippet_delete(request, snippet_id=None): """ Delete a snippet. This is allowed by anybody as long as he knows the snippet id. I got too many manual requests to do this, mostly for legal reasons and the chance to abuse this is not given anyway, since snippets always expire. """ + snippet_id = snippet_id or request.POST.get('snippet_id') + if not snippet_id: + raise Http404('No snippet id given') snippet = get_object_or_404(Snippet, secret_id=snippet_id) snippet.delete() return HttpResponseRedirect(reverse('snippet_new') + '?delete=1')