##// END OF EJS Templates
Added domain image for nv
Added domain image for nv

File last commit:

r1904:b612804b default
r1972:7389c05f default
Show More
utils.py
31 lines | 1.0 KiB | text/x-python | PythonLexer
neko259
Allow speed ban
r1899 from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_protect
neko259
Do not allow banning users by not a moderator. Show 403 error when posting as a banned user, not 500
r1902 from django.contrib.auth.decorators import permission_required
neko259
Allow speed ban
r1899 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')
neko259
Do not allow banning users by not a moderator. Show 403 error when posting as a banned user, not 500
r1902 @permission_required('boards.delete_post')
neko259
Allow speed ban
r1899 def ban_and_delete(self, request):
post = Post.objects.get(id=request.GET['post_id'])
Ban.objects.get_or_create(ip=post.poster_ip)
neko259
Delete thread when banning OP
r1901 if post.is_opening():
post.get_thread().delete()
else:
post.delete()
neko259
Allow speed ban
r1899
neko259
Ban user without removing a post
r1904 @permission_required('boards.add_ban')
def ban(self, request):
post = Post.objects.get(id=request.GET['post_id'])
Ban.objects.get_or_create(ip=post.poster_ip)