mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Allow anybody to delete a snippet.
I got too many requests in the past, most of because people created snippets via the API and can't delete them, or because of legal issues.
This commit is contained in:
parent
9b1d06a919
commit
2b402680f8
4 changed files with 39 additions and 2 deletions
|
@ -7,6 +7,11 @@ body {
|
|||
padding: 10px 0 40px 0;
|
||||
}
|
||||
|
||||
tt strong {
|
||||
background-color: #ffe699;
|
||||
outline: 3px solid #ffe699;
|
||||
}
|
||||
|
||||
/* Custom container */
|
||||
.container-fluid {
|
||||
margin: 0 auto;
|
||||
|
|
|
@ -50,6 +50,29 @@
|
|||
<div class="clearfix"></div>
|
||||
<hr class="clearfix">
|
||||
|
||||
<h3>Delete a snippet</h3>
|
||||
|
||||
<p>
|
||||
If you created a snippet with the API you can't delete it on the webpage
|
||||
since it's not in your history. You can delete a snippet here. Actually
|
||||
you can delete any snippet of anybody, as long as you know the short code.
|
||||
</p>
|
||||
<p>
|
||||
If you deleted a snippet because auf legal issues, please let me know
|
||||
that, I want to keep track of such things and try to avoid in future.
|
||||
</p>
|
||||
<p>
|
||||
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>
|
||||
</p>
|
||||
|
||||
<form method="POST" action="{% url "snippet_delete" %}">
|
||||
<input name="snippet_id"> <input type="Submit" value="Submit"/>
|
||||
</form>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<hr class="clearfix">
|
||||
|
||||
<h3>Imprint</h3>
|
||||
|
||||
<p><strong>Address:</strong></p>
|
||||
|
|
|
@ -5,6 +5,7 @@ urlpatterns = patterns('dpaste.views',
|
|||
url(r'^guess/$', 'guess_lexer', name='snippet_guess_lexer'),
|
||||
url(r'^diff/$', 'snippet_diff', name='snippet_diff'),
|
||||
url(r'^history/$', 'snippet_history', name='snippet_history'),
|
||||
url(r'^delete/$', 'snippet_delete', name='snippet_delete'),
|
||||
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/$', 'snippet_details', name='snippet_details'),
|
||||
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/delete/$', 'snippet_delete', name='snippet_delete'),
|
||||
url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/gist/$', 'snippet_gist', name='snippet_gist'),
|
||||
|
|
|
@ -125,16 +125,24 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h
|
|||
else:
|
||||
return response
|
||||
|
||||
def snippet_delete(request, snippet_id):
|
||||
def snippet_delete(request, snippet_id=None):
|
||||
snippet_id = snippet_id or request.POST.get('snippet_id')
|
||||
if not snippet_id:
|
||||
return HttpResponseBadRequest('No snippet given!')
|
||||
|
||||
snippet = get_object_or_404(Snippet, secret_id=snippet_id)
|
||||
"""
|
||||
Anybody can delete anybodys snippets now.
|
||||
|
||||
try:
|
||||
snippet_list = request.session['snippet_list']
|
||||
except KeyError:
|
||||
return HttpResponseForbidden('You have no recent snippet list, cookie error?')
|
||||
if not snippet.pk in snippet_list:
|
||||
return HttpResponseForbidden('That\'s not your snippet!')
|
||||
"""
|
||||
snippet.delete()
|
||||
return HttpResponseRedirect(reverse('snippet_new'))
|
||||
return HttpResponseRedirect(reverse('snippet_new') + '?delete=1')
|
||||
|
||||
def snippet_history(request, template_name='dpaste/snippet_list.html'):
|
||||
|
||||
|
|
Loading…
Reference in a new issue