##// END OF EJS Templates
Show localized tags under the proper letter section in all tags list. Cache localized tag name, not the whole view
Show localized tags under the proper letter section in all tags list. Cache localized tag name, not the whole view

File last commit:

r1090:a66d091f default
r1892:0808e889 default
Show More
middlewares.py
44 lines | 1008 B | text/x-python | PythonLexer
import pytz
from django.shortcuts import redirect
from django.utils import timezone
from boards import utils
from boards.models import Ban
SESSION_TIMEZONE = 'django_timezone'
RESPONSE_CONTENT_TYPE = 'Content-Type'
TYPE_HTML = 'text/html'
class BanMiddleware:
"""
This is run before showing the thread. Banned users don't need to see
anything
"""
def __init__(self):
pass
def process_view(self, request, view_func, view_args, view_kwargs):
if request.path != '/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('banned')
class TimezoneMiddleware(object):
def process_request(self, request):
tzname = request.session.get(SESSION_TIMEZONE)
if tzname:
timezone.activate(pytz.timezone(tzname))
else:
timezone.deactivate()