From 2b402680f8755f1c56253de62afac07194a97d8b Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 19 Jul 2013 09:54:18 +0200 Subject: [PATCH] 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. --- dpaste/static/dpaste/theme.css | 5 +++++ dpaste/templates/dpaste/about.html | 23 +++++++++++++++++++++++ dpaste/urls/dpaste.py | 1 + dpaste/views.py | 12 ++++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/dpaste/static/dpaste/theme.css b/dpaste/static/dpaste/theme.css index 915ce53..6595072 100644 --- a/dpaste/static/dpaste/theme.css +++ b/dpaste/static/dpaste/theme.css @@ -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; diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index e5f0fdc..1f328f4 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -50,6 +50,29 @@

+

Delete a snippet

+ +

+ 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. +

+

+ 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. +

+

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

+ +
+ +
+ +
+
+

Imprint

Address:

diff --git a/dpaste/urls/dpaste.py b/dpaste/urls/dpaste.py index 13f4dcd..5819c90 100644 --- a/dpaste/urls/dpaste.py +++ b/dpaste/urls/dpaste.py @@ -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[a-zA-Z0-9]+)/$', 'snippet_details', name='snippet_details'), url(r'^(?P[a-zA-Z0-9]+)/delete/$', 'snippet_delete', name='snippet_delete'), url(r'^(?P[a-zA-Z0-9]+)/gist/$', 'snippet_gist', name='snippet_gist'), diff --git a/dpaste/views.py b/dpaste/views.py index 3377b5e..9d0818a 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -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'):