##// END OF EJS Templates
Moved 404 page to class-based views
Moved 404 page to class-based views

File last commit:

r553:fd6431be 1.7-dev
r555:89908dc2 1.7-dev
Show More
ban.py
20 lines | 621 B | text/x-python | PythonLexer
from django.db import transaction
from boards.views.base import BaseBoardView
from boards.models import Post, Ban
class BanUserView(BaseBoardView):
@transaction.atomic
def get(self, request, post_id):
user = self._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)