##// END OF EJS Templates
Make everything inside monochrome post monochrome
Make everything inside monochrome post monochrome

File last commit:

r2005:00eae4e7 default
r2031:ebf5bcfa default
Show More
utils.py
31 lines | 1017 B | text/x-python | PythonLexer
from django.contrib.auth.decorators import permission_required
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_protect
from boards.models import Post, Ban
from boards.views.base import BaseBoardView
from boards.views.mixins import DispatcherMixin
class UtilsView(BaseBoardView, DispatcherMixin):
@method_decorator(csrf_protect)
def get(self, request):
self.dispatch_method(request)
return redirect('index')
@permission_required('boards.delete_post')
def ban_and_delete(self, request):
post = Post.objects.get(id=request.GET['post_id'])
Ban.objects.get_or_create(ip=post.poster_ip)
if post.is_opening():
post.get_thread().delete()
else:
post.delete()
@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)