##// END OF EJS Templates
Prevent zalgo inside posts
Prevent zalgo inside posts

File last commit:

r2018:9b956998 default
r2076:062b2b13 default
Show More
middlewares.py
42 lines | 1.0 KiB | text/x-python | PythonLexer
neko259
Added timezone support (time zone is selected in settings)
r1065 import pytz
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 from django.shortcuts import redirect
neko259
Added timezone support (time zone is selected in settings)
r1065 from django.utils import timezone
neko259
Fixed middlewares
r2018 from django.utils.deprecation import MiddlewareMixin
neko259
Added timezone support (time zone is selected in settings)
r1065
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 from boards import utils
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 from boards.models import Ban
neko259
Added a middleware to remove spaces between tags in HTML code
r444
neko259
Get one ban object, not filter them
r2012 PATH_BANNED = '/banned/'
neko259
Refactored views
r1090 SESSION_TIMEZONE = 'django_timezone'
neko259
Added a middleware to remove spaces between tags in HTML code
r444 RESPONSE_CONTENT_TYPE = 'Content-Type'
TYPE_HTML = 'text/html'
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210
neko259
Fixed middlewares
r2018 class BanMiddleware(MiddlewareMixin):
neko259
Added a middleware to remove spaces between tags in HTML code
r444 """
This is run before showing the thread. Banned users don't need to see
anything
"""
neko259
Fixed middlewares
r2018 def process_request(self, request):
neko259
Get one ban object, not filter them
r2012 if request.path != PATH_BANNED:
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 ip = utils.get_client_ip(request)
neko259
Get one ban object, not filter them
r2012 try:
ban = Ban.objects.get(ip=ip)
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210
neko259
Added ban reasons. Added write-only bans.
r340 if not ban.can_read:
neko259
Rewriting views to class-based
r542 return redirect('banned')
neko259
Get one ban object, not filter them
r2012 except Ban.DoesNotExist:
pass
neko259
Added timezone support (time zone is selected in settings)
r1065
neko259
Adapt to django-2.0
r1986
neko259
Fixed middlewares
r2018 class TimezoneMiddleware(MiddlewareMixin):
def process_request(self, request):
neko259
Refactored views
r1090 tzname = request.session.get(SESSION_TIMEZONE)
neko259
Added timezone support (time zone is selected in settings)
r1065 if tzname:
timezone.activate(pytz.timezone(tzname))
else:
timezone.deactivate()