Show More
@@ -1,5 +1,3 b'' | |||||
1 | import string |
|
|||
2 |
|
||||
3 |
|
|
1 | from django.db import transaction | |
4 | from django.shortcuts import render, redirect |
|
2 | from django.shortcuts import render, redirect | |
5 |
|
3 | |||
@@ -12,6 +10,7 b' from boards.views.banned import BannedVi' | |||||
12 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
10 | from boards.views.base import BaseBoardView, CONTEXT_FORM | |
13 | from boards.views.posting_mixin import PostMixin |
|
11 | from boards.views.posting_mixin import PostMixin | |
14 |
|
12 | |||
|
13 | ||||
15 | FORM_TAGS = 'tags' |
|
14 | FORM_TAGS = 'tags' | |
16 | FORM_TEXT = 'text' |
|
15 | FORM_TEXT = 'text' | |
17 | FORM_TITLE = 'title' |
|
16 | FORM_TITLE = 'title' | |
@@ -127,7 +126,9 b' class AllThreadsView(PostMixin, BaseBoar' | |||||
127 |
|
126 | |||
128 | post = Post.objects.create_post(title=title, text=text, image=image, |
|
127 | post = Post.objects.create_post(title=title, text=text, image=image, | |
129 | ip=ip, tags=tags) |
|
128 | ip=ip, tags=tags) | |
130 | # FIXME |
|
129 | ||
|
130 | # This is required to update the threads to which posts we have replied | |||
|
131 | # when creating this one | |||
131 | post.send_to_websocket(request) |
|
132 | post.send_to_websocket(request) | |
132 |
|
133 | |||
133 | if html_response: |
|
134 | if html_response: |
@@ -14,8 +14,12 b" CONTEXT_FORM = 'form'" | |||||
14 | class BaseBoardView(View): |
|
14 | class BaseBoardView(View): | |
15 |
|
15 | |||
16 | def get_context_data(self, **kwargs): |
|
16 | def get_context_data(self, **kwargs): | |
|
17 | """ | |||
|
18 | This method is deprecated. You need to use dicts instead of context | |||
|
19 | instances in all places it is used now. | |||
|
20 | """ | |||
|
21 | ||||
17 | request = kwargs['request'] |
|
22 | request = kwargs['request'] | |
18 | # context = self._default_context(request) |
|
|||
19 | context = RequestContext(request) |
|
23 | context = RequestContext(request) | |
20 |
|
24 | |||
21 | return context |
|
25 | return context |
@@ -1,3 +1,4 b'' | |||||
|
1 | PARAM_NEXT = 'next' | |||
1 | PARAMETER_METHOD = 'method' |
|
2 | PARAMETER_METHOD = 'method' | |
2 |
|
3 | |||
3 | from django.shortcuts import redirect |
|
4 | from django.shortcuts import redirect | |
@@ -13,8 +14,8 b' class RedirectNextMixin:' | |||||
13 | current view has finished its work. |
|
14 | current view has finished its work. | |
14 | """ |
|
15 | """ | |
15 |
|
16 | |||
16 |
if |
|
17 | if PARAM_NEXT in request.GET: | |
17 |
next_page = request.GET[ |
|
18 | next_page = request.GET[PARAM_NEXT] | |
18 | return HttpResponseRedirect(next_page) |
|
19 | return HttpResponseRedirect(next_page) | |
19 | else: |
|
20 | else: | |
20 | return redirect('index') |
|
21 | return redirect('index') |
@@ -5,6 +5,8 b' from boards.abstracts.settingsmanager im' | |||||
5 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
5 | from boards.views.base import BaseBoardView, CONTEXT_FORM | |
6 | from boards.forms import SettingsForm, PlainErrorList |
|
6 | from boards.forms import SettingsForm, PlainErrorList | |
7 |
|
7 | |||
|
8 | FORM_THEME = 'theme' | |||
|
9 | ||||
8 | CONTEXT_HIDDEN_TAGS = 'hidden_tags' |
|
10 | CONTEXT_HIDDEN_TAGS = 'hidden_tags' | |
9 |
|
11 | |||
10 |
|
12 | |||
@@ -16,7 +18,7 b' class SettingsView(BaseBoardView):' | |||||
16 |
|
18 | |||
17 | selected_theme = settings_manager.get_theme() |
|
19 | selected_theme = settings_manager.get_theme() | |
18 |
|
20 | |||
19 |
form = SettingsForm(initial={ |
|
21 | form = SettingsForm(initial={FORM_THEME: selected_theme}, | |
20 | error_class=PlainErrorList) |
|
22 | error_class=PlainErrorList) | |
21 |
|
23 | |||
22 | context[CONTEXT_FORM] = form |
|
24 | context[CONTEXT_FORM] = form | |
@@ -32,7 +34,7 b' class SettingsView(BaseBoardView):' | |||||
32 | form = SettingsForm(request.POST, error_class=PlainErrorList) |
|
34 | form = SettingsForm(request.POST, error_class=PlainErrorList) | |
33 |
|
35 | |||
34 | if form.is_valid(): |
|
36 | if form.is_valid(): | |
35 |
selected_theme = form.cleaned_data[ |
|
37 | selected_theme = form.cleaned_data[FORM_THEME] | |
36 |
|
38 | |||
37 | settings_manager.set_theme(selected_theme) |
|
39 | settings_manager.set_theme(selected_theme) | |
38 |
|
40 |
@@ -6,6 +6,9 b' from boards.views.all_threads import All' | |||||
6 | from boards.views.mixins import DispatcherMixin, RedirectNextMixin |
|
6 | from boards.views.mixins import DispatcherMixin, RedirectNextMixin | |
7 | from boards.forms import ThreadForm, PlainErrorList |
|
7 | from boards.forms import ThreadForm, PlainErrorList | |
8 |
|
8 | |||
|
9 | PARAM_HIDDEN_TAGS = 'hidden_tags' | |||
|
10 | PARAM_FAV_TAGS = 'fav_tags' | |||
|
11 | PARAM_TAG = 'tag' | |||
9 |
|
12 | |||
10 | __author__ = 'neko259' |
|
13 | __author__ = 'neko259' | |
11 |
|
14 | |||
@@ -25,10 +28,10 b' class TagView(AllThreadsView, Dispatcher' | |||||
25 | settings_manager = get_settings_manager(kwargs['request']) |
|
28 | settings_manager = get_settings_manager(kwargs['request']) | |
26 |
|
29 | |||
27 | tag = get_object_or_404(Tag, name=self.tag_name) |
|
30 | tag = get_object_or_404(Tag, name=self.tag_name) | |
28 |
context[ |
|
31 | context[PARAM_TAG] = tag | |
29 |
|
32 | |||
30 |
context[ |
|
33 | context[PARAM_FAV_TAGS] = settings_manager.get_fav_tags() | |
31 |
context[ |
|
34 | context[PARAM_HIDDEN_TAGS] = settings_manager.get_hidden_tags() | |
32 |
|
35 | |||
33 | return context |
|
36 | return context | |
34 |
|
37 |
@@ -118,13 +118,6 b' class ThreadView(BaseBoardView, PostMixi' | |||||
118 | """Add a new post (in thread or as a reply).""" |
|
118 | """Add a new post (in thread or as a reply).""" | |
119 |
|
119 | |||
120 | ip = utils.get_client_ip(request) |
|
120 | ip = utils.get_client_ip(request) | |
121 | is_banned = Ban.objects.filter(ip=ip).exists() |
|
|||
122 |
|
||||
123 | if is_banned: |
|
|||
124 | if html_response: |
|
|||
125 | return redirect(BannedView().as_view()) |
|
|||
126 | else: |
|
|||
127 | return None |
|
|||
128 |
|
121 | |||
129 | data = form.cleaned_data |
|
122 | data = form.cleaned_data | |
130 |
|
123 |
General Comments 0
You need to be logged in to leave comments.
Login now