##// END OF EJS Templates
Extracted some magic strings
Extracted some magic strings

File last commit:

r1993:564f7dbe default
r2002:a3d63355 default
Show More
base.py
32 lines | 763 B | text/x-python | PythonLexer
neko259
Rewriting views to class-based
r542 from django.db import transaction
from django.views.generic import View
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
neko259
Whitelist of IPs that will not be banned (starting from localhost)
r1993 from boards import utils, settings
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.models.user import Ban
neko259
Rewriting views to class-based
r542
BAN_REASON_SPAM = 'Autoban: spam bot'
neko259
Code cleanup part 2
r722 CONTEXT_FORM = 'form'
neko259
Rewriting views to class-based
r542
class BaseBoardView(View):
def get_context_data(self, **kwargs):
neko259
Fixed tag threads view
r919 return dict()
neko259
Rewriting views to class-based
r542
@transaction.atomic
def _ban_current_user(self, request):
"""
Add current user to the IP ban list
"""
ip = utils.get_client_ip(request)
neko259
Whitelist of IPs that will not be banned (starting from localhost)
r1993 whitelist = settings.get_list('Forms', 'BanWhitelist')
if not ip in whitelist:
ban, created = Ban.objects.get_or_create(ip=ip)
if created:
ban.can_read = False
ban.reason = BAN_REASON_SPAM
ban.save()
neko259
Rewriting views to class-based
r542