##// END OF EJS Templates
Removed strange 'exists' method in post manager, fixed tests in which it was...
Removed strange 'exists' method in post manager, fixed tests in which it was used

File last commit:

r340:1472a0a6 default
r396:0d260248 default
Show More
middlewares.py
18 lines | 582 B | text/x-python | PythonLexer
from django.shortcuts import redirect
from boards import views, utils
from boards.models import Ban
class BanMiddleware:
"""This is run before showing the thread. Banned users don't need to see
anything"""
def process_view(self, request, view_func, view_args, view_kwargs):
if view_func != views.you_are_banned:
ip = utils.get_client_ip(request)
bans = Ban.objects.filter(ip=ip)
if bans.exists():
ban = bans[0]
if not ban.can_read:
return redirect(views.you_are_banned)