##// END OF EJS Templates
Delete thread when banning OP
neko259 -
r1901:fd30e4ee default
parent child Browse files
Show More
@@ -1,21 +1,24 b''
1 from django.shortcuts import redirect
1 from django.shortcuts import redirect
2 from django.utils.decorators import method_decorator
2 from django.utils.decorators import method_decorator
3 from django.views.decorators.csrf import csrf_protect
3 from django.views.decorators.csrf import csrf_protect
4 from boards.views.base import BaseBoardView, CONTEXT_FORM
4 from boards.views.base import BaseBoardView, CONTEXT_FORM
5 from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD
5 from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD
6 from boards.models import Post, Ban
6 from boards.models import Post, Ban
7
7
8
8
9 class UtilsView(BaseBoardView, DispatcherMixin):
9 class UtilsView(BaseBoardView, DispatcherMixin):
10 @method_decorator(csrf_protect)
10 @method_decorator(csrf_protect)
11 def get(self, request):
11 def get(self, request):
12 self.dispatch_method(request)
12 self.dispatch_method(request)
13
13
14 return redirect('index')
14 return redirect('index')
15
15
16
16
17 def ban_and_delete(self, request):
17 def ban_and_delete(self, request):
18 post = Post.objects.get(id=request.GET['post_id'])
18 post = Post.objects.get(id=request.GET['post_id'])
19 Ban.objects.get_or_create(ip=post.poster_ip)
19 Ban.objects.get_or_create(ip=post.poster_ip)
20 post.delete()
20 if post.is_opening():
21 post.get_thread().delete()
22 else:
23 post.delete()
21
24
General Comments 0
You need to be logged in to leave comments. Login now