##// END OF EJS Templates
Don't run time conversion if Intl not available in browser. Also convert...
Don't run time conversion if Intl not available in browser. Also convert thread death time in archived threads

File last commit:

r730:447bb8d7 2.0-dev
r1023:0040ea34 default
Show More
ban.py
26 lines | 883 B | text/x-python | PythonLexer
from django.db import transaction
from django.shortcuts import get_object_or_404
from boards.abstracts.settingsmanager import PERMISSION_MODERATE, \
get_settings_manager
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):
post = get_object_or_404(Post, id=post_id)
settings_manager = get_settings_manager(request)
if settings_manager.has_permission(PERMISSION_MODERATE):
# 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)