Show More
@@ -0,0 +1,33 b'' | |||
|
1 | from django.shortcuts import render, redirect | |
|
2 | ||
|
3 | from boards.abstracts.settingsmanager import SettingsManager, \ | |
|
4 | PERMISSION_MODERATE | |
|
5 | from boards.forms import LoginForm, PlainErrorList | |
|
6 | from boards.views.base import BaseBoardView, CONTEXT_FORM | |
|
7 | ||
|
8 | ||
|
9 | __author__ = 'neko259' | |
|
10 | ||
|
11 | ||
|
12 | class LoginView(BaseBoardView): | |
|
13 | ||
|
14 | def get(self, request, form=None): | |
|
15 | context = self.get_context_data(request=request) | |
|
16 | ||
|
17 | if not form: | |
|
18 | form = LoginForm() | |
|
19 | context[CONTEXT_FORM] = form | |
|
20 | ||
|
21 | return render(request, 'boards/login.html', context) | |
|
22 | ||
|
23 | def post(self, request): | |
|
24 | form = LoginForm(request.POST, request.FILES, | |
|
25 | error_class=PlainErrorList) | |
|
26 | form.session = request.session | |
|
27 | ||
|
28 | if form.is_valid(): | |
|
29 | settings_manager = SettingsManager(request.session) | |
|
30 | settings_manager.add_permission(PERMISSION_MODERATE) | |
|
31 | return redirect('index') | |
|
32 | else: | |
|
33 | return self.get(request, form) |
@@ -0,0 +1,24 b'' | |||
|
1 | from django.shortcuts import render | |
|
2 | ||
|
3 | from boards.abstracts.settingsmanager import SettingsManager, \ | |
|
4 | PERMISSION_MODERATE | |
|
5 | from boards.forms import LoginForm | |
|
6 | from boards.views.base import BaseBoardView, CONTEXT_FORM | |
|
7 | ||
|
8 | ||
|
9 | __author__ = 'neko259' | |
|
10 | ||
|
11 | ||
|
12 | class LogoutView(BaseBoardView): | |
|
13 | ||
|
14 | def get(self, request, form=None): | |
|
15 | settings_manager = SettingsManager(request.session) | |
|
16 | settings_manager.del_permission(PERMISSION_MODERATE) | |
|
17 | ||
|
18 | context = self.get_context_data(request=request) | |
|
19 | ||
|
20 | if not form: | |
|
21 | form = LoginForm() | |
|
22 | context[CONTEXT_FORM] = form | |
|
23 | ||
|
24 | return render(request, 'boards/login.html', context) No newline at end of file |
@@ -52,7 +52,15 b' class SettingsManager:' | |||
|
52 | 52 | if not permissions: |
|
53 | 53 | permissions = [permission] |
|
54 | 54 | else: |
|
55 |
permissions |
|
|
55 | permissions.append(permission) | |
|
56 | self.set_setting(SETTING_PERMISSIONS, permissions) | |
|
57 | ||
|
58 | def del_permission(self, permission): | |
|
59 | permissions = self.get_setting(SETTING_PERMISSIONS) | |
|
60 | if not permissions: | |
|
61 | permissions = [] | |
|
62 | else: | |
|
63 | permissions.remove(permission) | |
|
56 | 64 | self.set_setting(SETTING_PERMISSIONS, permissions) |
|
57 | 65 | |
|
58 | 66 | def get_fav_tags(self): |
@@ -278,12 +278,6 b' class SettingsForm(NeboardForm):' | |||
|
278 | 278 | label=_('Theme')) |
|
279 | 279 | |
|
280 | 280 | |
|
281 | class ModeratorSettingsForm(SettingsForm): | |
|
282 | ||
|
283 | moderate = forms.BooleanField(required=False, label=_('Enable moderation ' | |
|
284 | 'panel')) | |
|
285 | ||
|
286 | ||
|
287 | 281 | class AddTagForm(NeboardForm): |
|
288 | 282 | |
|
289 | 283 | tag = forms.CharField(max_length=TAG_MAX_LENGTH, label=LABEL_TAG) |
@@ -305,4 +299,44 b' class AddTagForm(NeboardForm):' | |||
|
305 | 299 | |
|
306 | 300 | |
|
307 | 301 | class SearchForm(NeboardForm): |
|
308 | query = forms.CharField(max_length=500, label=LABEL_SEARCH, required=False) No newline at end of file | |
|
302 | query = forms.CharField(max_length=500, label=LABEL_SEARCH, required=False) | |
|
303 | ||
|
304 | ||
|
305 | class LoginForm(NeboardForm): | |
|
306 | ||
|
307 | password = forms.CharField() | |
|
308 | ||
|
309 | session = None | |
|
310 | ||
|
311 | def clean_password(self): | |
|
312 | password = self.cleaned_data['password'] | |
|
313 | if board_settings.MASTER_PASSWORD != password: | |
|
314 | raise forms.ValidationError(_('Invalid master password')) | |
|
315 | ||
|
316 | return password | |
|
317 | ||
|
318 | def _validate_login_speed(self): | |
|
319 | can_post = True | |
|
320 | ||
|
321 | if LAST_LOGIN_TIME in self.session: | |
|
322 | now = time.time() | |
|
323 | last_login_time = self.session[LAST_LOGIN_TIME] | |
|
324 | ||
|
325 | current_delay = int(now - last_login_time) | |
|
326 | ||
|
327 | if current_delay < board_settings.LOGIN_TIMEOUT: | |
|
328 | error_message = _('Wait %s minutes after last login') % str( | |
|
329 | (board_settings.LOGIN_TIMEOUT - current_delay) / 60) | |
|
330 | self._errors['password'] = self.error_class([error_message]) | |
|
331 | ||
|
332 | can_post = False | |
|
333 | ||
|
334 | if can_post: | |
|
335 | self.session[LAST_LOGIN_TIME] = time.time() | |
|
336 | ||
|
337 | def clean(self): | |
|
338 | self._validate_login_speed() | |
|
339 | ||
|
340 | cleaned_data = super(LoginForm, self).clean() | |
|
341 | ||
|
342 | return cleaned_data |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -7,7 +7,7 b' msgid ""' | |||
|
7 | 7 | msgstr "" |
|
8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
|
9 | 9 | "Report-Msgid-Bugs-To: \n" |
|
10 |
"POT-Creation-Date: 2014-0 |
|
|
10 | "POT-Creation-Date: 2014-07-05 18:10+0300\n" | |
|
11 | 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|
12 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|
13 | 13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
@@ -18,19 +18,19 b' msgstr ""' | |||
|
18 | 18 | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" |
|
19 | 19 | "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" |
|
20 | 20 | |
|
21 |
#: authors.py: |
|
|
21 | #: authors.py:9 | |
|
22 | 22 | msgid "author" |
|
23 | 23 | msgstr "Π°Π²ΡΠΎΡ" |
|
24 | 24 | |
|
25 |
#: authors.py: |
|
|
25 | #: authors.py:10 | |
|
26 | 26 | msgid "developer" |
|
27 | 27 | msgstr "ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊ" |
|
28 | 28 | |
|
29 |
#: authors.py: |
|
|
29 | #: authors.py:11 | |
|
30 | 30 | msgid "javascript developer" |
|
31 | 31 | msgstr "ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊ javascript" |
|
32 | 32 | |
|
33 |
#: authors.py: |
|
|
33 | #: authors.py:12 | |
|
34 | 34 | msgid "designer" |
|
35 | 35 | msgstr "Π΄ΠΈΠ·Π°ΠΉΠ½Π΅Ρ" |
|
36 | 36 | |
@@ -62,7 +62,7 b' msgstr "\xd0\xa2\xd0\xb5\xd0\xba\xd1\x81\xd1\x82"' | |||
|
62 | 62 | msgid "Tag" |
|
63 | 63 | msgstr "Π’Π΅Π³" |
|
64 | 64 | |
|
65 |
#: forms.py:32 templates/boards/base.html:5 |
|
|
65 | #: forms.py:32 templates/boards/base.html:54 templates/search/search.html:9 | |
|
66 | 66 | #: templates/search/search.html.py:13 |
|
67 | 67 | msgid "Search" |
|
68 | 68 | msgstr "ΠΠΎΠΈΡΠΊ" |
@@ -71,59 +71,55 b' msgstr "\xd0\x9f\xd0\xbe\xd0\xb8\xd1\x81\xd0\xba"' | |||
|
71 | 71 | msgid "Image" |
|
72 | 72 | msgstr "ΠΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅" |
|
73 | 73 | |
|
74 |
#: forms.py:11 |
|
|
74 | #: forms.py:114 | |
|
75 | 75 | msgid "e-mail" |
|
76 | 76 | msgstr "" |
|
77 | 77 | |
|
78 |
#: forms.py:12 |
|
|
78 | #: forms.py:125 | |
|
79 | 79 | #, python-format |
|
80 | 80 | msgid "Title must have less than %s characters" |
|
81 | 81 | msgstr "ΠΠ°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΈΠΌΠ΅ΡΡ ΠΌΠ΅Π½ΡΡΠ΅ %s ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²" |
|
82 | 82 | |
|
83 |
#: forms.py:13 |
|
|
83 | #: forms.py:134 | |
|
84 | 84 | #, python-format |
|
85 | 85 | msgid "Text must have less than %s characters" |
|
86 | 86 | msgstr "Π’Π΅ΠΊΡΡ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΊΠΎΡΠΎΡΠ΅ %s ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²" |
|
87 | 87 | |
|
88 |
#: forms.py:14 |
|
|
88 | #: forms.py:145 | |
|
89 | 89 | #, python-format |
|
90 | 90 | msgid "Image must be less than %s bytes" |
|
91 | 91 | msgstr "ΠΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ ΠΌΠ΅Π½Π΅Π΅ %s Π±Π°ΠΉΡ" |
|
92 | 92 | |
|
93 |
#: forms.py:1 |
|
|
93 | #: forms.py:180 | |
|
94 | 94 | msgid "Either text or image must be entered." |
|
95 | 95 | msgstr "Π’Π΅ΠΊΡΡ ΠΈΠ»ΠΈ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ° Π΄ΠΎΠ»ΠΆΠ½Ρ Π±ΡΡΡ Π²Π²Π΅Π΄Π΅Π½Ρ." |
|
96 | 96 | |
|
97 |
#: forms.py:20 |
|
|
97 | #: forms.py:200 | |
|
98 | 98 | #, python-format |
|
99 | 99 | msgid "Wait %s seconds after last posting" |
|
100 | 100 | msgstr "ΠΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡΠ΅ %s ΡΠ΅ΠΊΡΠ½Π΄ ΠΏΠΎΡΠ»Π΅ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅Π³ΠΎ ΠΏΠΎΡΡΠΈΠ½Π³Π°" |
|
101 | 101 | |
|
102 |
#: forms.py:21 |
|
|
102 | #: forms.py:216 templates/boards/tags.html:7 templates/boards/rss/post.html:10 | |
|
103 | 103 | msgid "Tags" |
|
104 | 104 | msgstr "Π’Π΅Π³ΠΈ" |
|
105 | 105 | |
|
106 |
#: forms.py:22 |
|
|
106 | #: forms.py:223 forms.py:291 | |
|
107 | 107 | msgid "Inappropriate characters in tags." |
|
108 | 108 | msgstr "ΠΠ΅Π΄ΠΎΠΏΡΡΡΠΈΠΌΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ Π² ΡΠ΅Π³Π°Ρ ." |
|
109 | 109 | |
|
110 |
#: forms.py:25 |
|
|
110 | #: forms.py:251 forms.py:272 | |
|
111 | 111 | msgid "Captcha validation failed" |
|
112 | 112 | msgstr "ΠΡΠΎΠ²Π΅ΡΠΊΠ° ΠΊΠ°ΠΏΡΠΈ ΠΏΡΠΎΠ²Π°Π»Π΅Π½Π°" |
|
113 | 113 | |
|
114 |
#: forms.py:28 |
|
|
114 | #: forms.py:278 | |
|
115 | 115 | msgid "Theme" |
|
116 | 116 | msgstr "Π’Π΅ΠΌΠ°" |
|
117 | 117 | |
|
118 |
#: forms.py: |
|
|
119 | msgid "Enable moderation panel" | |
|
120 | msgstr "ΠΠΊΠ»ΡΡΠΈΡΡ ΠΏΠ°Π½Π΅Π»Ρ ΠΌΠΎΠ΄Π΅ΡΠ°ΡΠΈΠΈ" | |
|
118 | #: forms.py:314 | |
|
119 | msgid "Invalid master password" | |
|
120 | msgstr "ΠΠ΅Π²Π΅ΡΠ½ΡΠΉ ΠΌΠ°ΡΡΠ΅Ρ-ΠΏΠ°ΡΠΎΠ»Ρ" | |
|
121 | 121 | |
|
122 |
#: forms.py:3 |
|
|
123 | msgid "No such user found" | |
|
124 | msgstr "ΠΠ°Π½Π½ΡΠΉ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½" | |
|
125 | ||
|
126 | #: forms.py:314 | |
|
122 | #: forms.py:328 | |
|
127 | 123 | #, python-format |
|
128 | 124 | msgid "Wait %s minutes after last login" |
|
129 | 125 | msgstr "ΠΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡΠ΅ %s ΠΌΠΈΠ½ΡΡ ΠΏΠΎΡΠ»Π΅ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅Π³ΠΎ Π²Ρ ΠΎΠ΄Π°" |
@@ -168,17 +164,21 b' msgstr "\xd0\xa3\xd0\xbf\xd1\x80\xd0\xb0\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5 \xd1\x82\xd0\xb5\xd0\xb3\xd0\xb0\xd0\xbc\xd0\xb8"' | |||
|
168 | 164 | msgid "Settings" |
|
169 | 165 | msgstr "ΠΠ°ΡΡΡΠΎΠΉΠΊΠΈ" |
|
170 | 166 | |
|
171 |
#: templates/boards/base.html: |
|
|
167 | #: templates/boards/base.html:50 | |
|
168 | msgid "Logout" | |
|
169 | msgstr "ΠΡΡ ΠΎΠ΄" | |
|
170 | ||
|
171 | #: templates/boards/base.html:52 templates/boards/login.html:6 | |
|
172 | 172 | #: templates/boards/login.html.py:16 |
|
173 | 173 | msgid "Login" |
|
174 | 174 | msgstr "ΠΡ ΠΎΠ΄" |
|
175 | 175 | |
|
176 |
#: templates/boards/base.html:5 |
|
|
176 | #: templates/boards/base.html:56 | |
|
177 | 177 | #, python-format |
|
178 | 178 | msgid "Speed: %(ppd)s posts per day" |
|
179 | 179 | msgstr "Π‘ΠΊΠΎΡΠΎΡΡΡ: %(ppd)s ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠΉ Π² Π΄Π΅Π½Ρ" |
|
180 | 180 | |
|
181 |
#: templates/boards/base.html:5 |
|
|
181 | #: templates/boards/base.html:58 | |
|
182 | 182 | msgid "Up" |
|
183 | 183 | msgstr "ΠΠ²Π΅ΡΡ " |
|
184 | 184 | |
@@ -249,7 +249,7 b' msgstr "\xd0\x9f\xd1\x80\xd0\xb5\xd0\xb4\xd1\x8b\xd0\xb4\xd1\x83\xd1\x89\xd0\xb0\xd1\x8f \xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0"' | |||
|
249 | 249 | msgid "Skipped %(count)s replies. Open thread to see all replies." |
|
250 | 250 | msgstr "ΠΡΠΎΠΏΡΡΠ΅Π½ΠΎ %(count)s ΠΎΡΠ²Π΅ΡΠΎΠ². ΠΡΠΊΡΠΎΠΉΡΠ΅ ΡΡΠ΅Π΄, ΡΡΠΎΠ±Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ Π²ΡΠ΅ ΠΎΡΠ²Π΅ΡΡ." |
|
251 | 251 | |
|
252 |
#: templates/boards/posting_general.html:121 templates/search/search.html:3 |
|
|
252 | #: templates/boards/posting_general.html:121 templates/search/search.html:33 | |
|
253 | 253 | msgid "Next page" |
|
254 | 254 | msgstr "Π‘Π»Π΅Π΄ΡΡΡΠ°Ρ ΡΡΡΠ°Π½ΠΈΡΠ°" |
|
255 | 255 | |
@@ -278,35 +278,15 b' msgstr "\xd0\xa1\xd0\xb8\xd0\xbd\xd1\x82\xd0\xb0\xd0\xba\xd1\x81\xd0\xb8\xd1\x81 \xd1\x82\xd0\xb5\xd0\xba\xd1\x81\xd1\x82\xd0\xb0"' | |||
|
278 | 278 | msgid "Pages:" |
|
279 | 279 | msgstr "Π‘ΡΡΠ°Π½ΠΈΡΡ: " |
|
280 | 280 | |
|
281 |
#: templates/boards/settings.html:1 |
|
|
282 | msgid "User:" | |
|
283 | msgstr "ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ:" | |
|
284 | ||
|
285 | #: templates/boards/settings.html:16 | |
|
281 | #: templates/boards/settings.html:15 | |
|
286 | 282 | msgid "You are moderator." |
|
287 | 283 | msgstr "ΠΡ ΠΌΠΎΠ΄Π΅ΡΠ°ΡΠΎΡ." |
|
288 | 284 | |
|
289 |
#: templates/boards/settings.html: |
|
|
290 | msgid "You are veteran." | |
|
291 | msgstr "ΠΡ Π²Π΅ΡΠ΅ΡΠ°Π½." | |
|
292 | ||
|
293 | #: templates/boards/settings.html:22 | |
|
294 | msgid "Posts:" | |
|
295 | msgstr "Π‘ΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠΉ:" | |
|
296 | ||
|
297 | #: templates/boards/settings.html:23 | |
|
298 | msgid "First access:" | |
|
299 | msgstr "ΠΠ΅ΡΠ²ΡΠΉ Π΄ΠΎΡΡΡΠΏ:" | |
|
300 | ||
|
301 | #: templates/boards/settings.html:25 | |
|
302 | msgid "Last access:" | |
|
303 | msgstr "ΠΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ Π΄ΠΎΡΡΡΠΏ: " | |
|
304 | ||
|
305 | #: templates/boards/settings.html:29 | |
|
285 | #: templates/boards/settings.html:20 | |
|
306 | 286 | msgid "Hidden tags:" |
|
307 | 287 | msgstr "Π‘ΠΊΡΡΡΡΠ΅ ΡΠ΅Π³ΠΈ:" |
|
308 | 288 | |
|
309 |
#: templates/boards/settings.html: |
|
|
289 | #: templates/boards/settings.html:35 | |
|
310 | 290 | msgid "Save" |
|
311 | 291 | msgstr "Π‘ΠΎΡ ΡΠ°Π½ΠΈΡΡ" |
|
312 | 292 | |
@@ -385,8 +365,4 b' msgstr "\xd0\x9f\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb4 \xd1\x8d\xd1\x82\xd0\xb8\xd0\xbc\xd0\xb8 \xd1\x82\xd0\xb5\xd0\xb3\xd0\xb0\xd0\xbc\xd0\xb8 \xd0\xbd\xd1\x83\xd0\xb6\xd0\xbd\xd0\xb0 \xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x8f \xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0:"' | |||
|
385 | 365 | |
|
386 | 366 | #: templates/boards/staticpages/help.html:18 |
|
387 | 367 | msgid "Comment" |
|
388 |
msgstr "ΠΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ" |
|
|
389 | ||
|
390 | #: templates/search/search.html:30 | |
|
391 | msgid "No results found." | |
|
392 | msgstr "Π Π΅Π·ΡΠ»ΡΡΠ°ΡΡ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½Ρ." | |
|
368 | msgstr "ΠΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ" No newline at end of file |
@@ -17,4 +17,7 b' LAST_REPLIES_COUNT = 3' | |||
|
17 | 17 | # Enable archiving threads instead of deletion when the thread limit is reached |
|
18 | 18 | ARCHIVE_THREADS = True |
|
19 | 19 | # Limit posting speed |
|
20 | LIMIT_POSTING_SPEED = False No newline at end of file | |
|
20 | LIMIT_POSTING_SPEED = False | |
|
21 | ||
|
22 | # This password is used to add admin permissions to the user | |
|
23 | MASTER_PASSWORD = u'password' No newline at end of file |
@@ -46,6 +46,11 b'' | |||
|
46 | 46 | |
|
47 | 47 | <div class="navigation_panel"> |
|
48 | 48 | {% block metapanel %}{% endblock %} |
|
49 | {% if moderator %} | |
|
50 | [<a href="{% url "logout" %}">{% trans 'Logout' %}</a>] | |
|
51 | {% else %} | |
|
52 | [<a href="{% url "login" %}">{% trans 'Login' %}</a>] | |
|
53 | {% endif %} | |
|
49 | 54 | [<a href="{% url "search" %}">{% trans 'Search' %}</a>] |
|
50 | 55 | {% with ppd=posts_per_day|floatformat:2 %} |
|
51 | 56 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} |
@@ -2,7 +2,7 b' from django.conf.urls import patterns, u' | |||
|
2 | 2 | from boards import views |
|
3 | 3 | from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed |
|
4 | 4 | from boards.views import api, tag_threads, all_threads, \ |
|
5 |
|
|
|
5 | login, settings, all_tags, logout | |
|
6 | 6 | from boards.views.authors import AuthorsView |
|
7 | 7 | from boards.views.delete_post import DeletePostView |
|
8 | 8 | from boards.views.ban import BanUserView |
@@ -22,6 +22,10 b" urlpatterns = patterns(''," | |||
|
22 | 22 | url(r'^page/(?P<page>\w+)/$', all_threads.AllThreadsView.as_view(), |
|
23 | 23 | name='index'), |
|
24 | 24 | |
|
25 | # login page | |
|
26 | url(r'^login/$', login.LoginView.as_view(), name='login'), | |
|
27 | url(r'^logout/$', logout.LogoutView.as_view(), name='logout'), | |
|
28 | ||
|
25 | 29 | # /boards/tag/tag_name/ |
|
26 | 30 | url(r'^tag/(?P<tag_name>\w+)/$', tag_threads.TagView.as_view(), |
|
27 | 31 | name='tag'), |
@@ -1,12 +1,9 b'' | |||
|
1 | 1 | from django.db import transaction |
|
2 | 2 | from django.shortcuts import render, redirect |
|
3 | from boards import utils | |
|
4 | from boards.abstracts.settingsmanager import SettingsManager, \ | |
|
5 | PERMISSION_MODERATE | |
|
3 | from boards.abstracts.settingsmanager import SettingsManager | |
|
6 | 4 | |
|
7 | 5 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
8 |
from boards.forms import SettingsForm, |
|
|
9 | from boards.models.post import SETTING_MODERATE | |
|
6 | from boards.forms import SettingsForm, PlainErrorList | |
|
10 | 7 | |
|
11 | 8 | |
|
12 | 9 | class SettingsView(BaseBoardView): |
@@ -14,16 +11,9 b' class SettingsView(BaseBoardView):' | |||
|
14 | 11 | def get(self, request): |
|
15 | 12 | context = self.get_context_data(request=request) |
|
16 | 13 | settings_manager = SettingsManager(request.session) |
|
17 | is_moderator = settings_manager.has_permission(PERMISSION_MODERATE) | |
|
18 | 14 | |
|
19 | 15 | selected_theme = settings_manager.get_theme() |
|
20 | 16 | |
|
21 | if is_moderator: | |
|
22 | form = ModeratorSettingsForm(initial={ | |
|
23 | 'theme': selected_theme, | |
|
24 | 'moderate': settings_manager.has_permission(PERMISSION_MODERATE) | |
|
25 | }, error_class=PlainErrorList) | |
|
26 | else: | |
|
27 | 17 |
|
|
28 | 18 |
|
|
29 | 19 | |
@@ -33,13 +23,8 b' class SettingsView(BaseBoardView):' | |||
|
33 | 23 | |
|
34 | 24 | def post(self, request): |
|
35 | 25 | settings_manager = SettingsManager(request.session) |
|
36 | is_moderator = settings_manager.has_permission(PERMISSION_MODERATE) | |
|
37 | 26 | |
|
38 | 27 | with transaction.atomic(): |
|
39 | if is_moderator: | |
|
40 | form = ModeratorSettingsForm(request.POST, | |
|
41 | error_class=PlainErrorList) | |
|
42 | else: | |
|
43 | 28 |
|
|
44 | 29 | |
|
45 | 30 | if form.is_valid(): |
@@ -47,9 +32,4 b' class SettingsView(BaseBoardView):' | |||
|
47 | 32 | |
|
48 | 33 | settings_manager.set_theme(selected_theme) |
|
49 | 34 | |
|
50 | if is_moderator: | |
|
51 | moderate = form.cleaned_data['moderate'] | |
|
52 | if moderate == 'True': | |
|
53 | settings_manager.add_permission(PERMISSION_MODERATE) | |
|
54 | ||
|
55 | 35 | return redirect('settings') |
General Comments 0
You need to be logged in to leave comments.
Login now