##// END OF EJS Templates
Run js highlight on the new posts only, not on all page each time. Add...
Run js highlight on the new posts only, not on all page each time. Add highlight to the reflink popups

File last commit:

r690:a8dffe47 1.8-dev
r709:e6788412 default
Show More
ban.py
24 lines | 763 B | text/x-python | PythonLexer
from django.db import transaction
from django.shortcuts import get_object_or_404
from boards import utils
from boards.views.base import BaseBoardView
from boards.models import Post, Ban
from boards.views.mixins import RedirectNextMixin
class BanUserView(BaseBoardView, RedirectNextMixin):
@transaction.atomic
def get(self, request, post_id):
user = utils.get_user(request)
post = get_object_or_404(Post, id=post_id)
if user.is_moderator():
# TODO Show confirmation page before ban
ban, created = Ban.objects.get_or_create(ip=post.poster_ip)
if created:
ban.reason = 'Banned for post ' + str(post_id)
ban.save()
return self.redirect_to_next(request)