##// END OF EJS Templates
Fixed thread update
Fixed thread update

File last commit:

r690:a8dffe47 1.8-dev
r710:3be7d3c8 default
Show More
base.py
35 lines | 814 B | text/x-python | PythonLexer
neko259
Rewriting views to class-based
r542 from django.db import transaction
from django.template import RequestContext
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
Rewriting views to class-based
r542 from boards import utils
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'
PARAMETER_FORM = 'form'
class BaseBoardView(View):
def get_context_data(self, **kwargs):
request = kwargs['request']
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 # context = self._default_context(request)
neko259
Rewriting views to class-based
r542 context = RequestContext(request)
return context
@transaction.atomic
def _ban_current_user(self, request):
"""
Add current user to the IP ban list
"""
ip = utils.get_client_ip(request)
ban, created = Ban.objects.get_or_create(ip=ip)
if created:
ban.can_read = False
ban.reason = BAN_REASON_SPAM
ban.save()