mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Fixed snippet delete function.
This commit is contained in:
parent
6e641290e2
commit
e34c46f9aa
2 changed files with 5 additions and 2 deletions
|
@ -63,7 +63,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Type the 5 letter code of your snippet in the field and submit.
|
Type the 5 letter code of your snippet in the field and submit.
|
||||||
Like this yellow one here: <tt>http://dpaste.de/<strong>SiZrT</strong>/</tt>
|
Like this yellow one here: <tt>http://dpaste.de/<strong>SiZrT</strong></tt>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form method="POST" action="{% url "snippet_delete" %}">
|
<form method="POST" action="{% url "snippet_delete" %}">
|
||||||
|
|
|
@ -104,13 +104,16 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h
|
||||||
return response
|
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
|
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
|
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
|
reasons and the chance to abuse this is not given anyway, since snippets
|
||||||
always expire.
|
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 = get_object_or_404(Snippet, secret_id=snippet_id)
|
||||||
snippet.delete()
|
snippet.delete()
|
||||||
return HttpResponseRedirect(reverse('snippet_new') + '?delete=1')
|
return HttpResponseRedirect(reverse('snippet_new') + '?delete=1')
|
||||||
|
|
Loading…
Reference in a new issue