diff --git a/boards/views/all_threads.py b/boards/views/all_threads.py --- a/boards/views/all_threads.py +++ b/boards/views/all_threads.py @@ -1,5 +1,3 @@ -import string - from django.db import transaction from django.shortcuts import render, redirect @@ -12,6 +10,7 @@ from boards.views.banned import BannedVi from boards.views.base import BaseBoardView, CONTEXT_FORM from boards.views.posting_mixin import PostMixin + FORM_TAGS = 'tags' FORM_TEXT = 'text' FORM_TITLE = 'title' @@ -127,7 +126,9 @@ class AllThreadsView(PostMixin, BaseBoar post = Post.objects.create_post(title=title, text=text, image=image, ip=ip, tags=tags) - # FIXME + + # This is required to update the threads to which posts we have replied + # when creating this one post.send_to_websocket(request) if html_response: diff --git a/boards/views/base.py b/boards/views/base.py --- a/boards/views/base.py +++ b/boards/views/base.py @@ -14,8 +14,12 @@ CONTEXT_FORM = 'form' class BaseBoardView(View): def get_context_data(self, **kwargs): + """ + This method is deprecated. You need to use dicts instead of context + instances in all places it is used now. + """ + request = kwargs['request'] - # context = self._default_context(request) context = RequestContext(request) return context diff --git a/boards/views/mixins.py b/boards/views/mixins.py --- a/boards/views/mixins.py +++ b/boards/views/mixins.py @@ -1,3 +1,4 @@ +PARAM_NEXT = 'next' PARAMETER_METHOD = 'method' from django.shortcuts import redirect @@ -13,8 +14,8 @@ class RedirectNextMixin: current view has finished its work. """ - if 'next' in request.GET: - next_page = request.GET['next'] + if PARAM_NEXT in request.GET: + next_page = request.GET[PARAM_NEXT] return HttpResponseRedirect(next_page) else: return redirect('index') diff --git a/boards/views/settings.py b/boards/views/settings.py --- a/boards/views/settings.py +++ b/boards/views/settings.py @@ -5,6 +5,8 @@ from boards.abstracts.settingsmanager im from boards.views.base import BaseBoardView, CONTEXT_FORM from boards.forms import SettingsForm, PlainErrorList +FORM_THEME = 'theme' + CONTEXT_HIDDEN_TAGS = 'hidden_tags' @@ -16,7 +18,7 @@ class SettingsView(BaseBoardView): selected_theme = settings_manager.get_theme() - form = SettingsForm(initial={'theme': selected_theme}, + form = SettingsForm(initial={FORM_THEME: selected_theme}, error_class=PlainErrorList) context[CONTEXT_FORM] = form @@ -32,7 +34,7 @@ class SettingsView(BaseBoardView): form = SettingsForm(request.POST, error_class=PlainErrorList) if form.is_valid(): - selected_theme = form.cleaned_data['theme'] + selected_theme = form.cleaned_data[FORM_THEME] settings_manager.set_theme(selected_theme) diff --git a/boards/views/tag_threads.py b/boards/views/tag_threads.py --- a/boards/views/tag_threads.py +++ b/boards/views/tag_threads.py @@ -6,6 +6,9 @@ from boards.views.all_threads import All from boards.views.mixins import DispatcherMixin, RedirectNextMixin from boards.forms import ThreadForm, PlainErrorList +PARAM_HIDDEN_TAGS = 'hidden_tags' +PARAM_FAV_TAGS = 'fav_tags' +PARAM_TAG = 'tag' __author__ = 'neko259' @@ -25,10 +28,10 @@ class TagView(AllThreadsView, Dispatcher settings_manager = get_settings_manager(kwargs['request']) tag = get_object_or_404(Tag, name=self.tag_name) - context['tag'] = tag + context[PARAM_TAG] = tag - context['fav_tags'] = settings_manager.get_fav_tags() - context['hidden_tags'] = settings_manager.get_hidden_tags() + context[PARAM_FAV_TAGS] = settings_manager.get_fav_tags() + context[PARAM_HIDDEN_TAGS] = settings_manager.get_hidden_tags() return context diff --git a/boards/views/thread.py b/boards/views/thread.py --- a/boards/views/thread.py +++ b/boards/views/thread.py @@ -118,13 +118,6 @@ class ThreadView(BaseBoardView, PostMixi """Add a new post (in thread or as a reply).""" ip = utils.get_client_ip(request) - is_banned = Ban.objects.filter(ip=ip).exists() - - if is_banned: - if html_response: - return redirect(BannedView().as_view()) - else: - return None data = form.cleaned_data