##// END OF EJS Templates
Added link to the pub-time sorted thread list
neko259 -
r1376:a9439dbc default
parent child Browse files
Show More
1 NO CONTENT: modified file, binary diff hidden
@@ -1,490 +1,493 b''
1 1 # SOME DESCRIPTIVE TITLE.
2 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3 3 # This file is distributed under the same license as the PACKAGE package.
4 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 5 #
6 6 msgid ""
7 7 msgstr ""
8 8 "Project-Id-Version: PACKAGE VERSION\n"
9 9 "Report-Msgid-Bugs-To: \n"
10 10 "POT-Creation-Date: 2015-10-09 23:21+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"
14 14 "Language: ru\n"
15 15 "MIME-Version: 1.0\n"
16 16 "Content-Type: text/plain; charset=UTF-8\n"
17 17 "Content-Transfer-Encoding: 8bit\n"
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 21 #: admin.py:22
22 22 msgid "{} posters were banned"
23 23 msgstr ""
24 24
25 25 #: authors.py:9
26 26 msgid "author"
27 27 msgstr "автор"
28 28
29 29 #: authors.py:10
30 30 msgid "developer"
31 31 msgstr "разработчик"
32 32
33 33 #: authors.py:11
34 34 msgid "javascript developer"
35 35 msgstr "разработчик javascript"
36 36
37 37 #: authors.py:12
38 38 msgid "designer"
39 39 msgstr "дизайнер"
40 40
41 41 #: forms.py:30
42 42 msgid "Type message here. Use formatting panel for more advanced usage."
43 43 msgstr ""
44 44 "Вводите сообщение сюда. Используйте панель для более сложного форматирования."
45 45
46 46 #: forms.py:31
47 47 msgid "music images i_dont_like_tags"
48 48 msgstr "музыка картинки теги_не_нужны"
49 49
50 50 #: forms.py:33
51 51 msgid "Title"
52 52 msgstr "Заголовок"
53 53
54 54 #: forms.py:34
55 55 msgid "Text"
56 56 msgstr "Текст"
57 57
58 58 #: forms.py:35
59 59 msgid "Tag"
60 60 msgstr "Метка"
61 61
62 62 #: forms.py:36 templates/boards/base.html:40 templates/search/search.html:7
63 63 msgid "Search"
64 64 msgstr "Поиск"
65 65
66 66 #: forms.py:139
67 67 msgid "File"
68 68 msgstr "Файл"
69 69
70 70 #: forms.py:142
71 71 msgid "File URL"
72 72 msgstr "URL файла"
73 73
74 74 #: forms.py:148
75 75 msgid "e-mail"
76 76 msgstr ""
77 77
78 78 #: forms.py:151
79 79 msgid "Additional threads"
80 80 msgstr "Дополнительные темы"
81 81
82 82 #: forms.py:162
83 83 #, python-format
84 84 msgid "Title must have less than %s characters"
85 85 msgstr "Заголовок должен иметь меньше %s символов"
86 86
87 87 #: forms.py:172
88 88 #, python-format
89 89 msgid "Text must have less than %s characters"
90 90 msgstr "Текст должен быть короче %s символов"
91 91
92 92 #: forms.py:192
93 93 msgid "Invalid URL"
94 94 msgstr "Неверный URL"
95 95
96 96 #: forms.py:213
97 97 msgid "Invalid additional thread list"
98 98 msgstr "Неверный список дополнительных тем"
99 99
100 100 #: forms.py:258
101 101 msgid "Either text or file must be entered."
102 102 msgstr "Текст или файл должны быть введены."
103 103
104 104 #: forms.py:317 templates/boards/all_threads.html:153
105 105 #: templates/boards/rss/post.html:10 templates/boards/tags.html:6
106 106 msgid "Tags"
107 107 msgstr "Метки"
108 108
109 109 #: forms.py:324
110 110 msgid "Inappropriate characters in tags."
111 111 msgstr "Недопустимые символы в метках."
112 112
113 113 #: forms.py:344
114 114 msgid "Need at least one section."
115 115 msgstr "Нужен хотя бы один раздел."
116 116
117 117 #: forms.py:356
118 118 msgid "Theme"
119 119 msgstr "Тема"
120 120
121 121 #: forms.py:357
122 122 msgid "Image view mode"
123 123 msgstr "Режим просмотра изображений"
124 124
125 125 #: forms.py:358
126 126 msgid "User name"
127 127 msgstr "Имя пользователя"
128 128
129 129 #: forms.py:359
130 130 msgid "Time zone"
131 131 msgstr "Часовой пояс"
132 132
133 133 #: forms.py:365
134 134 msgid "Inappropriate characters."
135 135 msgstr "Недопустимые символы."
136 136
137 137 #: templates/boards/404.html:6
138 138 msgid "Not found"
139 139 msgstr "Не найдено"
140 140
141 141 #: templates/boards/404.html:12
142 142 msgid "This page does not exist"
143 143 msgstr "Этой страницы не существует"
144 144
145 145 #: templates/boards/all_threads.html:35
146 146 msgid "Related message"
147 147 msgstr "Связанное сообщение"
148 148
149 149 #: templates/boards/all_threads.html:69
150 150 msgid "Edit tag"
151 151 msgstr "Изменить метку"
152 152
153 153 #: templates/boards/all_threads.html:76
154 154 #, python-format
155 155 msgid "%(count)s active thread"
156 156 msgid_plural "%(count)s active threads"
157 157 msgstr[0] "%(count)s активная тема"
158 158 msgstr[1] "%(count)s активные темы"
159 159 msgstr[2] "%(count)s активных тем"
160 160
161 161 #: templates/boards/all_threads.html:77
162 162 #, python-format
163 163 msgid "%(count)s archived thread"
164 164 msgid_plural "%(count)s archived thread"
165 165 msgstr[0] "%(count)s архивная тема"
166 166 msgstr[1] "%(count)s архивные темы"
167 167 msgstr[2] "%(count)s архивных тем"
168 168
169 169 #: templates/boards/all_threads.html:78 templates/boards/post.html:102
170 170 #, python-format
171 171 #| msgid "%(count)s message"
172 172 #| msgid_plural "%(count)s messages"
173 173 msgid "%(count)s message"
174 174 msgid_plural "%(count)s messages"
175 175 msgstr[0] "%(count)s сообщение"
176 176 msgstr[1] "%(count)s сообщения"
177 177 msgstr[2] "%(count)s сообщений"
178 178
179 179 #: templates/boards/all_threads.html:95 templates/boards/feed.html:30
180 180 #: templates/boards/notifications.html:17 templates/search/search.html:26
181 181 msgid "Previous page"
182 182 msgstr "Предыдущая страница"
183 183
184 184 #: templates/boards/all_threads.html:109
185 185 #, python-format
186 186 msgid "Skipped %(count)s reply. Open thread to see all replies."
187 187 msgid_plural "Skipped %(count)s replies. Open thread to see all replies."
188 188 msgstr[0] "Пропущен %(count)s ответ. Откройте тред, чтобы увидеть все ответы."
189 189 msgstr[1] ""
190 190 "Пропущено %(count)s ответа. Откройте тред, чтобы увидеть все ответы."
191 191 msgstr[2] ""
192 192 "Пропущено %(count)s ответов. Откройте тред, чтобы увидеть все ответы."
193 193
194 194 #: templates/boards/all_threads.html:127 templates/boards/feed.html:40
195 195 #: templates/boards/notifications.html:27 templates/search/search.html:37
196 196 msgid "Next page"
197 197 msgstr "Следующая страница"
198 198
199 199 #: templates/boards/all_threads.html:132
200 200 msgid "No threads exist. Create the first one!"
201 201 msgstr "Нет тем. Создайте первую!"
202 202
203 203 #: templates/boards/all_threads.html:138
204 204 msgid "Create new thread"
205 205 msgstr "Создать новую тему"
206 206
207 207 #: templates/boards/all_threads.html:143 templates/boards/preview.html:16
208 208 #: templates/boards/thread_normal.html:51
209 209 msgid "Post"
210 210 msgstr "Отправить"
211 211
212 212 #: templates/boards/all_threads.html:144 templates/boards/preview.html:6
213 213 #: templates/boards/staticpages/help.html:21
214 214 #: templates/boards/thread_normal.html:52
215 215 msgid "Preview"
216 216 msgstr "Предпросмотр"
217 217
218 218 #: templates/boards/all_threads.html:149
219 219 msgid "Tags must be delimited by spaces. Text or image is required."
220 220 msgstr ""
221 221 "Метки должны быть разделены пробелами. Текст или изображение обязательны."
222 222
223 223 #: templates/boards/all_threads.html:152 templates/boards/thread_normal.html:58
224 224 msgid "Text syntax"
225 225 msgstr "Синтаксис текста"
226 226
227 227 #: templates/boards/all_threads.html:166 templates/boards/feed.html:53
228 228 msgid "Pages:"
229 229 msgstr "Страницы: "
230 230
231 231 #: templates/boards/authors.html:6 templates/boards/authors.html.py:12
232 232 msgid "Authors"
233 233 msgstr "Авторы"
234 234
235 235 #: templates/boards/authors.html:26
236 236 msgid "Distributed under the"
237 237 msgstr "Распространяется под"
238 238
239 239 #: templates/boards/authors.html:28
240 240 msgid "license"
241 241 msgstr "лицензией"
242 242
243 243 #: templates/boards/authors.html:30
244 244 msgid "Repository"
245 245 msgstr "Репозиторий"
246 246
247 247 #: templates/boards/base.html:14 templates/boards/base.html.py:41
248 248 msgid "Feed"
249 249 msgstr "Лента"
250 250
251 251 #: templates/boards/base.html:31
252 252 msgid "All threads"
253 253 msgstr "Все темы"
254 254
255 255 #: templates/boards/base.html:37
256 256 msgid "Add tags"
257 257 msgstr "Добавить метки"
258 258
259 259 #: templates/boards/base.html:39
260 260 msgid "Tag management"
261 261 msgstr "Управление метками"
262 262
263 263 #: templates/boards/base.html:39
264 264 msgid "tags"
265 265 msgstr "метки"
266 266
267 267 #: templates/boards/base.html:40
268 268 msgid "search"
269 269 msgstr "поиск"
270 270
271 271 #: templates/boards/base.html:41 templates/boards/feed.html:11
272 272 msgid "feed"
273 273 msgstr "лента"
274 274
275 275 #: templates/boards/base.html:42 templates/boards/random.html:6
276 276 msgid "Random images"
277 277 msgstr "Случайные изображения"
278 278
279 279 #: templates/boards/base.html:42
280 280 msgid "random"
281 281 msgstr "случайные"
282 282
283 283 #: templates/boards/base.html:44
284 284 msgid "favorites"
285 285 msgstr "избранное"
286 286
287 287 #: templates/boards/base.html:48 templates/boards/base.html.py:49
288 288 #: templates/boards/notifications.html:8
289 289 msgid "Notifications"
290 290 msgstr "Уведомления"
291 291
292 292 #: templates/boards/base.html:56 templates/boards/settings.html:8
293 293 msgid "Settings"
294 294 msgstr "Настройки"
295 295
296 296 #: templates/boards/base.html:59
297 297 msgid "Loading..."
298 298 msgstr "Загрузка..."
299 299
300 300 #: templates/boards/base.html:71
301 301 msgid "Admin"
302 302 msgstr "Администрирование"
303 303
304 304 #: templates/boards/base.html:73
305 305 #, python-format
306 306 msgid "Speed: %(ppd)s posts per day"
307 307 msgstr "Скорость: %(ppd)s сообщений в день"
308 308
309 309 #: templates/boards/base.html:75
310 310 msgid "Up"
311 311 msgstr "Вверх"
312 312
313 313 #: templates/boards/feed.html:45
314 314 msgid "No posts exist. Create the first one!"
315 315 msgstr "Нет сообщений. Создайте первое!"
316 316
317 317 #: templates/boards/post.html:33
318 318 msgid "Open"
319 319 msgstr "Открыть"
320 320
321 321 #: templates/boards/post.html:35 templates/boards/post.html.py:46
322 322 msgid "Reply"
323 323 msgstr "Ответить"
324 324
325 325 #: templates/boards/post.html:41
326 326 msgid " in "
327 327 msgstr " в "
328 328
329 329 #: templates/boards/post.html:51
330 330 msgid "Edit"
331 331 msgstr "Изменить"
332 332
333 333 #: templates/boards/post.html:53
334 334 msgid "Edit thread"
335 335 msgstr "Изменить тему"
336 336
337 337 #: templates/boards/post.html:91
338 338 msgid "Replies"
339 339 msgstr "Ответы"
340 340
341 341 #: templates/boards/post.html:103
342 342 #, python-format
343 343 msgid "%(count)s image"
344 344 msgid_plural "%(count)s images"
345 345 msgstr[0] "%(count)s изображение"
346 346 msgstr[1] "%(count)s изображения"
347 347 msgstr[2] "%(count)s изображений"
348 348
349 349 #: templates/boards/rss/post.html:5
350 350 msgid "Post image"
351 351 msgstr "Изображение сообщения"
352 352
353 353 #: templates/boards/settings.html:15
354 354 msgid "You are moderator."
355 355 msgstr "Вы модератор."
356 356
357 357 #: templates/boards/settings.html:19
358 358 msgid "Hidden tags:"
359 359 msgstr "Скрытые метки:"
360 360
361 361 #: templates/boards/settings.html:25
362 362 msgid "No hidden tags."
363 363 msgstr "Нет скрытых меток."
364 364
365 365 #: templates/boards/settings.html:34
366 366 msgid "Save"
367 367 msgstr "Сохранить"
368 368
369 369 #: templates/boards/staticpages/banned.html:6
370 370 msgid "Banned"
371 371 msgstr "Заблокирован"
372 372
373 373 #: templates/boards/staticpages/banned.html:11
374 374 msgid "Your IP address has been banned. Contact the administrator"
375 375 msgstr "Ваш IP адрес был заблокирован. Свяжитесь с администратором"
376 376
377 377 #: templates/boards/staticpages/help.html:6
378 378 #: templates/boards/staticpages/help.html:10
379 379 msgid "Syntax"
380 380 msgstr "Синтаксис"
381 381
382 382 #: templates/boards/staticpages/help.html:11
383 383 msgid "Italic text"
384 384 msgstr "Курсивный текст"
385 385
386 386 #: templates/boards/staticpages/help.html:12
387 387 msgid "Bold text"
388 388 msgstr "Полужирный текст"
389 389
390 390 #: templates/boards/staticpages/help.html:13
391 391 msgid "Spoiler"
392 392 msgstr "Спойлер"
393 393
394 394 #: templates/boards/staticpages/help.html:14
395 395 msgid "Link to a post"
396 396 msgstr "Ссылка на сообщение"
397 397
398 398 #: templates/boards/staticpages/help.html:15
399 399 msgid "Strikethrough text"
400 400 msgstr "Зачеркнутый текст"
401 401
402 402 #: templates/boards/staticpages/help.html:16
403 403 msgid "Comment"
404 404 msgstr "Комментарий"
405 405
406 406 #: templates/boards/staticpages/help.html:17
407 407 #: templates/boards/staticpages/help.html:18
408 408 msgid "Quote"
409 409 msgstr "Цитата"
410 410
411 411 #: templates/boards/staticpages/help.html:21
412 412 msgid "You can try pasting the text and previewing the result here:"
413 413 msgstr "Вы можете попробовать вставить текст и проверить результат здесь:"
414 414
415 415 #: templates/boards/tags.html:17
416 416 msgid "Sections:"
417 417 msgstr "Разделы:"
418 418
419 419 #: templates/boards/tags.html:30
420 420 msgid "Other tags:"
421 421 msgstr "Другие метки:"
422 422
423 423 #: templates/boards/tags.html:43
424 424 msgid "All tags..."
425 425 msgstr "Все метки..."
426 426
427 427 #: templates/boards/thread.html:14
428 428 msgid "Normal"
429 429 msgstr "Нормальный"
430 430
431 431 #: templates/boards/thread.html:15
432 432 msgid "Gallery"
433 433 msgstr "Галерея"
434 434
435 435 #: templates/boards/thread.html:16
436 436 msgid "Tree"
437 437 msgstr "Дерево"
438 438
439 439 #: templates/boards/thread.html:35
440 440 msgid "message"
441 441 msgid_plural "messages"
442 442 msgstr[0] "сообщение"
443 443 msgstr[1] "сообщения"
444 444 msgstr[2] "сообщений"
445 445
446 446 #: templates/boards/thread.html:38
447 447 msgid "image"
448 448 msgid_plural "images"
449 449 msgstr[0] "изображение"
450 450 msgstr[1] "изображения"
451 451 msgstr[2] "изображений"
452 452
453 453 #: templates/boards/thread.html:40
454 454 msgid "Last update: "
455 455 msgstr "Последнее обновление: "
456 456
457 457 #: templates/boards/thread_gallery.html:36
458 458 msgid "No images."
459 459 msgstr "Нет изображений."
460 460
461 461 #: templates/boards/thread_normal.html:30
462 462 msgid "posts to bumplimit"
463 463 msgstr "сообщений до бамплимита"
464 464
465 465 #: templates/boards/thread_normal.html:44
466 466 msgid "Reply to thread"
467 467 msgstr "Ответить в тему"
468 468
469 469 #: templates/boards/thread_normal.html:44
470 470 msgid "to message "
471 471 msgstr "на сообщение"
472 472
473 473 #: templates/boards/thread_normal.html:59
474 474 msgid "Close form"
475 475 msgstr "Закрыть форму"
476 476
477 477 #: templates/search/search.html:17
478 478 msgid "Ok"
479 479 msgstr "Ок"
480 480
481 481 #: utils.py:120
482 482 #, python-format
483 483 msgid "File must be less than %s bytes"
484 484 msgstr "Файл должен быть менее %s байт"
485 485
486 486 msgid "Please wait %(delay)d second before sending message"
487 487 msgid_plural "Please wait %(delay)d seconds before sending message"
488 488 msgstr[0] "Пожалуйста подождите %(delay)d секунду перед отправкой сообщения"
489 489 msgstr[1] "Пожалуйста подождите %(delay)d секунды перед отправкой сообщения"
490 490 msgstr[2] "Пожалуйста подождите %(delay)d секунд перед отправкой сообщения"
491
492 msgid "New threads"
493 msgstr "Новые темы"
@@ -1,79 +1,80 b''
1 1 {% load staticfiles %}
2 2 {% load i18n %}
3 3 {% load l10n %}
4 4 {% load static from staticfiles %}
5 5
6 6 <!DOCTYPE html>
7 7 <html>
8 8 <head>
9 9 <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}" media="all"/>
10 10 <link rel="stylesheet" type="text/css" href="{% static 'css/3party/highlight.css' %}" media="all"/>
11 11 <link rel="stylesheet" type="text/css" href="{% static 'css/3party/jquery-ui.min.css' %}" media="all"/>
12 12 <link rel="stylesheet" type="text/css" href="{% static theme_css %}" media="all"/>
13 13
14 14 <link rel="alternate" type="application/rss+xml" href="rss/" title="{% trans 'Feed' %}"/>
15 15
16 16 <link rel="icon" type="image/png"
17 17 href="{% static 'favicon.png' %}">
18 18
19 19 <meta name="viewport" content="width=device-width, initial-scale=1"/>
20 20 <meta charset="utf-8"/>
21 21
22 22 {% block head %}{% endblock %}
23 23 </head>
24 24 <body data-image-viewer="{{ image_viewer }}">
25 25 <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script>
26 26 <script src="{% static 'js/3party/jquery-ui.min.js' %}"></script>
27 27 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
28 28 <script src="{% url 'js_info_dict' %}"></script>
29 29
30 30 <div class="navigation_panel header">
31 31 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
32 32 {% if tags_str %}
33 33 {% autoescape off %}
34 34 {{ tags_str }},
35 35 {% endautoescape %}
36 36 {% else %}
37 37 {% trans 'Add tags' %} →
38 38 {% endif %}
39 39 <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>,
40 40 <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>,
41 41 <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>,
42 42 <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a>{% if has_fav_threads %},
43 43
44 44 <a href="#" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count"></span></a>
45 45 {% endif %}
46 46
47 47 {% if username %}
48 48 <a class="right-link link" href="{% url 'notifications' username %}" title="{% trans 'Notifications' %}">
49 49 {% trans 'Notifications' %}
50 50 {% ifnotequal new_notifications_count 0 %}
51 51 (<b>{{ new_notifications_count }}</b>)
52 52 {% endifnotequal %}
53 53 </a>
54 54 {% endif %}
55 55
56 56 <a class="right-link link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
57 57 </div>
58 58
59 59 <div id="fav-panel"><div class="post">{% trans "Loading..." %}</div></div>
60 60
61 61 {% block content %}{% endblock %}
62 62
63 63 <script src="{% static 'js/3party/highlight.min.js' %}"></script>
64 64 <script src="{% static 'js/popup.js' %}"></script>
65 65 <script src="{% static 'js/image.js' %}"></script>
66 66 <script src="{% static 'js/refpopup.js' %}"></script>
67 67 <script src="{% static 'js/main.js' %}"></script>
68 68
69 69 <div class="navigation_panel footer">
70 70 {% block metapanel %}{% endblock %}
71 71 [<a href="{% url 'admin:index' %}">{% trans 'Admin' %}</a>]
72 [<a href="{% url 'index' %}?order=pub">{% trans 'New threads' %}</a>]
72 73 {% with ppd=posts_per_day|floatformat:2 %}
73 74 {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %}
74 75 {% endwith %}
75 76 <a class="link" href="#top" id="up">{% trans 'Up' %}</a>
76 77 </div>
77 78
78 79 </body>
79 80 </html>
@@ -1,157 +1,166 b''
1 1 from django.core.urlresolvers import reverse
2 2 from django.core.files import File
3 3 from django.core.files.temp import NamedTemporaryFile
4 4 from django.core.paginator import EmptyPage
5 5 from django.db import transaction
6 6 from django.http import Http404
7 7 from django.shortcuts import render, redirect
8 8 import requests
9 9
10 10 from boards import utils, settings
11 11 from boards.abstracts.paginator import get_paginator
12 12 from boards.abstracts.settingsmanager import get_settings_manager
13 13 from boards.forms import ThreadForm, PlainErrorList
14 14 from boards.models import Post, Thread, Ban, Tag, PostImage, Banner
15 15 from boards.views.banned import BannedView
16 16 from boards.views.base import BaseBoardView, CONTEXT_FORM
17 17 from boards.views.posting_mixin import PostMixin
18 18
19 19
20 20 FORM_TAGS = 'tags'
21 21 FORM_TEXT = 'text'
22 22 FORM_TITLE = 'title'
23 23 FORM_IMAGE = 'image'
24 24 FORM_THREADS = 'threads'
25 25
26 26 TAG_DELIMITER = ' '
27 27
28 28 PARAMETER_CURRENT_PAGE = 'current_page'
29 29 PARAMETER_PAGINATOR = 'paginator'
30 30 PARAMETER_THREADS = 'threads'
31 31 PARAMETER_BANNERS = 'banners'
32 32
33 33 PARAMETER_PREV_LINK = 'prev_page_link'
34 34 PARAMETER_NEXT_LINK = 'next_page_link'
35 35
36 36 TEMPLATE = 'boards/all_threads.html'
37 37 DEFAULT_PAGE = 1
38 38
39 39
40 40 class AllThreadsView(PostMixin, BaseBoardView):
41 41
42 42 def __init__(self):
43 43 self.settings_manager = None
44 44 super(AllThreadsView, self).__init__()
45 45
46 46 def get(self, request, form: ThreadForm=None):
47 47 page = request.GET.get('page', DEFAULT_PAGE)
48 48
49 49 params = self.get_context_data(request=request)
50 50
51 51 if not form:
52 52 form = ThreadForm(error_class=PlainErrorList)
53 53
54 54 self.settings_manager = get_settings_manager(request)
55 paginator = get_paginator(self.get_threads().order_by('-bump_time'),
55
56 threads = self.get_threads()
57
58 order = request.GET.get('order', 'bump')
59 if order == 'bump':
60 threads = threads.order_by('-bump_time')
61 else:
62 threads = threads.filter(multi_replies__opening=True).order_by('-multi_replies__pub_time')
63
64 paginator = get_paginator(threads,
56 65 settings.get_int('View', 'ThreadsPerPage'))
57 66 paginator.current_page = int(page)
58 67
59 68 try:
60 69 threads = paginator.page(page).object_list
61 70 except EmptyPage:
62 71 raise Http404()
63 72
64 73 params[PARAMETER_THREADS] = threads
65 74 params[CONTEXT_FORM] = form
66 75 params[PARAMETER_BANNERS] = Banner.objects.order_by('-id').all()
67 76
68 77 self.get_page_context(paginator, params, page, request.GET.dict())
69 78
70 79 return render(request, TEMPLATE, params)
71 80
72 81 def post(self, request):
73 82 form = ThreadForm(request.POST, request.FILES,
74 83 error_class=PlainErrorList)
75 84 form.session = request.session
76 85
77 86 if form.is_valid():
78 87 return self.create_thread(request, form)
79 88 if form.need_to_ban:
80 89 # Ban user because he is suspected to be a bot
81 90 self._ban_current_user(request)
82 91
83 92 return self.get(request, form)
84 93
85 94 def get_page_context(self, paginator, params, page, url_params):
86 95 """
87 96 Get pagination context variables
88 97 """
89 98
90 99 params[PARAMETER_PAGINATOR] = paginator
91 100 current_page = paginator.page(int(page))
92 101 params[PARAMETER_CURRENT_PAGE] = current_page
93 102 if current_page.has_previous():
94 103 params[PARAMETER_PREV_LINK] = self.get_previous_page_link(
95 104 current_page, url_params)
96 105 if current_page.has_next():
97 106 params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page,
98 107 url_params)
99 108
100 109 def get_previous_page_link(self, current_page, params):
101 110 params['page'] = current_page.previous_page_number()
102 111 return self.get_reverse_url(params)
103 112
104 113 def get_next_page_link(self, current_page, params):
105 114 params['page'] = current_page.next_page_number()
106 115 return self.get_reverse_url(params)
107 116
108 117 def get_url_params(self, params):
109 118 return '?' + '&'.join(['{}={}'.format(key, params[key]) for key in params.keys()])
110 119
111 120 def get_reverse_url(self, params):
112 121 return reverse('index') + self.get_url_params(params)
113 122
114 123 @transaction.atomic
115 124 def create_thread(self, request, form: ThreadForm, html_response=True):
116 125 """
117 126 Creates a new thread with an opening post.
118 127 """
119 128
120 129 ip = utils.get_client_ip(request)
121 130 is_banned = Ban.objects.filter(ip=ip).exists()
122 131
123 132 if is_banned:
124 133 if html_response:
125 134 return redirect(BannedView().as_view())
126 135 else:
127 136 return
128 137
129 138 data = form.cleaned_data
130 139
131 140 title = form.get_title()
132 141 text = data[FORM_TEXT]
133 142 file = form.get_file()
134 143 threads = data[FORM_THREADS]
135 144
136 145 text = self._remove_invalid_links(text)
137 146
138 147 tags = data[FORM_TAGS]
139 148
140 149 post = Post.objects.create_post(title=title, text=text, file=file,
141 150 ip=ip, tags=tags, opening_posts=threads,
142 151 tripcode=form.get_tripcode())
143 152
144 153 # This is required to update the threads to which posts we have replied
145 154 # when creating this one
146 155 post.notify_clients()
147 156
148 157 if html_response:
149 158 return redirect(post.get_absolute_url())
150 159
151 160 def get_threads(self):
152 161 """
153 162 Gets list of threads that will be shown on a page.
154 163 """
155 164
156 165 return Thread.objects\
157 166 .exclude(tags__in=self.settings_manager.get_hidden_tags())
General Comments 0
You need to be logged in to leave comments. Login now