##// END OF EJS Templates
Moved some settings to boards.settings
Moved some settings to boards.settings

File last commit:

r210:952de927 default
r333:c4e2cbcd default
Show More
middlewares.py
16 lines | 521 B | text/x-python | PythonLexer
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 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)
is_banned = Ban.objects.filter(ip=ip).exists()
if is_banned:
return redirect(views.you_are_banned)