diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html
--- a/boards/templates/boards/post.html
+++ b/boards/templates/boards/post.html
@@ -98,6 +98,13 @@
window.location = '{% url 'post_sync_data' post.id %}';
},
visible: {% if post.global_id_id %}true{% else %}false{% endif %}
+ },
+ banAndDelete: {
+ name: 'Ban and delete',
+ callback: function(key, opt) {
+ window.location = '{% url 'utils' %}?method=ban_and_delete&post_id={{ post.id }}';
+ },
+ visible: {% if post.has_ip %}true{% else %}false{% endif %}
}
}
};
diff --git a/boards/urls.py b/boards/urls.py
--- a/boards/urls.py
+++ b/boards/urls.py
@@ -16,6 +16,7 @@ from boards.views.tag_gallery import Tag
from boards.views.translation import cached_javascript_catalog
from boards.views.search import BoardSearchView
from boards.views.landing import LandingView
+from boards.views.utils import UtilsView
js_info_dict = {
@@ -53,6 +54,7 @@ urlpatterns = [
url(r'^tag/(?P\w+)/gallery/$', TagGalleryView.as_view(), name='tag_gallery'),
url(r'^search/$', BoardSearchView.as_view(), name='search'),
url(r'^$', LandingView.as_view(), name='landing'),
+ url(r'^utils$', UtilsView.as_view(), name='utils'),
# RSS feeds
url(r'^rss/$', AllThreadsFeed()),
diff --git a/boards/views/utils.py b/boards/views/utils.py
new file mode 100644
--- /dev/null
+++ b/boards/views/utils.py
@@ -0,0 +1,21 @@
+from django.shortcuts import redirect
+from django.utils.decorators import method_decorator
+from django.views.decorators.csrf import csrf_protect
+from boards.views.base import BaseBoardView, CONTEXT_FORM
+from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD
+from boards.models import Post, Ban
+
+
+class UtilsView(BaseBoardView, DispatcherMixin):
+ @method_decorator(csrf_protect)
+ def get(self, request):
+ self.dispatch_method(request)
+
+ return redirect('index')
+
+
+ def ban_and_delete(self, request):
+ post = Post.objects.get(id=request.GET['post_id'])
+ Ban.objects.get_or_create(ip=post.poster_ip)
+ post.delete()
+