Show More
@@ -0,0 +1,85 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | from south.utils import datetime_utils as datetime | |||
|
3 | from south.db import db | |||
|
4 | from south.v2 import SchemaMigration | |||
|
5 | from django.db import models | |||
|
6 | ||||
|
7 | ||||
|
8 | class Migration(SchemaMigration): | |||
|
9 | ||||
|
10 | def forwards(self, orm): | |||
|
11 | # Adding field 'Thread.archived' | |||
|
12 | db.add_column(u'boards_thread', 'archived', | |||
|
13 | self.gf('django.db.models.fields.BooleanField')(default=0), | |||
|
14 | keep_default=False) | |||
|
15 | ||||
|
16 | ||||
|
17 | def backwards(self, orm): | |||
|
18 | # Deleting field 'Thread.archived' | |||
|
19 | db.delete_column(u'boards_thread', 'archived') | |||
|
20 | ||||
|
21 | ||||
|
22 | models = { | |||
|
23 | 'boards.ban': { | |||
|
24 | 'Meta': {'object_name': 'Ban'}, | |||
|
25 | 'can_read': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), | |||
|
26 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
27 | 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), | |||
|
28 | 'reason': ('django.db.models.fields.CharField', [], {'default': "'Auto'", 'max_length': '200'}) | |||
|
29 | }, | |||
|
30 | 'boards.post': { | |||
|
31 | 'Meta': {'object_name': 'Post'}, | |||
|
32 | '_text_rendered': ('django.db.models.fields.TextField', [], {}), | |||
|
33 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
34 | 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), | |||
|
35 | 'image_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
36 | 'image_pre_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
37 | 'image_pre_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
38 | 'image_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
39 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
40 | 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), | |||
|
41 | 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), | |||
|
42 | 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
43 | 'referenced_posts': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'rfp+'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['boards.Post']"}), | |||
|
44 | 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), | |||
|
45 | 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), | |||
|
46 | 'thread': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['boards.Post']", 'null': 'True'}), | |||
|
47 | 'thread_new': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['boards.Thread']", 'null': 'True'}), | |||
|
48 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
49 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['boards.User']", 'null': 'True'}) | |||
|
50 | }, | |||
|
51 | 'boards.setting': { | |||
|
52 | 'Meta': {'object_name': 'Setting'}, | |||
|
53 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
54 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
55 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['boards.User']"}), | |||
|
56 | 'value': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
57 | }, | |||
|
58 | 'boards.tag': { | |||
|
59 | 'Meta': {'object_name': 'Tag'}, | |||
|
60 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
61 | 'linked': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['boards.Tag']", 'null': 'True', 'blank': 'True'}), | |||
|
62 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |||
|
63 | 'threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'tag+'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['boards.Thread']"}) | |||
|
64 | }, | |||
|
65 | 'boards.thread': { | |||
|
66 | 'Meta': {'object_name': 'Thread'}, | |||
|
67 | 'archived': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | |||
|
68 | 'bump_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
69 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
70 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
71 | 'replies': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'tre+'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['boards.Post']"}), | |||
|
72 | 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['boards.Tag']", 'symmetrical': 'False'}) | |||
|
73 | }, | |||
|
74 | 'boards.user': { | |||
|
75 | 'Meta': {'object_name': 'User'}, | |||
|
76 | 'fav_tags': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['boards.Tag']", 'null': 'True', 'blank': 'True'}), | |||
|
77 | 'fav_threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['boards.Post']"}), | |||
|
78 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
79 | 'rank': ('django.db.models.fields.IntegerField', [], {}), | |||
|
80 | 'registration_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
81 | 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
82 | } | |||
|
83 | } | |||
|
84 | ||||
|
85 | complete_apps = ['boards'] No newline at end of file |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -7,7 +7,7 b' msgid ""' | |||||
7 | msgstr "" |
|
7 | msgstr "" | |
8 | "Project-Id-Version: PACKAGE VERSION\n" |
|
8 | "Project-Id-Version: PACKAGE VERSION\n" | |
9 | "Report-Msgid-Bugs-To: \n" |
|
9 | "Report-Msgid-Bugs-To: \n" | |
10 |
"POT-Creation-Date: 201 |
|
10 | "POT-Creation-Date: 2014-01-06 21:37+0200\n" | |
11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|
11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |
12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|
12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
|
13 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
@@ -74,8 +74,7 b' msgstr "\xd0\xa2\xd0\xb5\xd0\xba\xd1\x81\xd1\x82 \xd0\xb8\xd0\xbb\xd0\xb8 \xd0\xba\xd0\xb0\xd1\x80\xd1\x82\xd0\xb8\xd0\xbd\xd0\xba\xd0\xb0 \xd0\xb4\xd0\xbe\xd0\xbb\xd0\xb6\xd0\xbd\xd1\x8b \xd0\xb1\xd1\x8b\xd1\x82\xd1\x8c \xd0\xb2\xd0\xb2\xd0\xb5\xd0\xb4\xd0\xb5\xd0\xbd\xd1\x8b."' | |||||
74 | msgid "Wait %s seconds after last posting" |
|
74 | msgid "Wait %s seconds after last posting" | |
75 | msgstr "Подождите %s секунд после последнего постинга" |
|
75 | msgstr "Подождите %s секунд после последнего постинга" | |
76 |
|
76 | |||
77 |
#: forms.py:163 templates/boards/ |
|
77 | #: forms.py:163 templates/boards/tags.html:6 templates/boards/rss/post.html:10 | |
78 | #: templates/boards/rss/post.html:10 |
|
|||
79 | msgid "Tags" |
|
78 | msgid "Tags" | |
80 | msgstr "Теги" |
|
79 | msgstr "Теги" | |
81 |
|
80 | |||
@@ -112,6 +111,43 b' msgstr "\xd0\x9d\xd0\xb5 \xd0\xbd\xd0\xb0\xd0\xb9\xd0\xb4\xd0\xb5\xd0\xbd\xd0\xbe"' | |||||
112 | msgid "This page does not exist" |
|
111 | msgid "This page does not exist" | |
113 | msgstr "Этой страницы не существует" |
|
112 | msgstr "Этой страницы не существует" | |
114 |
|
113 | |||
|
114 | #: templates/boards/archive.html:45 templates/boards/posting_general.html:64 | |||
|
115 | msgid "Previous page" | |||
|
116 | msgstr "Предыдущая страница" | |||
|
117 | ||||
|
118 | #: templates/boards/archive.html:77 templates/boards/post.html:37 | |||
|
119 | #: templates/boards/posting_general.html:103 templates/boards/thread.html:69 | |||
|
120 | msgid "Delete" | |||
|
121 | msgstr "Удалить" | |||
|
122 | ||||
|
123 | #: templates/boards/archive.html:81 templates/boards/post.html:40 | |||
|
124 | #: templates/boards/posting_general.html:107 templates/boards/thread.html:72 | |||
|
125 | msgid "Ban IP" | |||
|
126 | msgstr "Заблокировать IP" | |||
|
127 | ||||
|
128 | #: templates/boards/archive.html:90 templates/boards/post.html:53 | |||
|
129 | #: templates/boards/posting_general.html:116 | |||
|
130 | #: templates/boards/posting_general.html:180 templates/boards/thread.html:81 | |||
|
131 | msgid "Replies" | |||
|
132 | msgstr "Ответы" | |||
|
133 | ||||
|
134 | #: templates/boards/archive.html:99 templates/boards/posting_general.html:125 | |||
|
135 | #: templates/boards/thread.html:138 templates/boards/thread_gallery.html:58 | |||
|
136 | msgid "images" | |||
|
137 | msgstr "изображений" | |||
|
138 | ||||
|
139 | #: templates/boards/archive.html:124 templates/boards/posting_general.html:203 | |||
|
140 | msgid "Next page" | |||
|
141 | msgstr "Следующая страница" | |||
|
142 | ||||
|
143 | #: templates/boards/archive.html:129 templates/boards/posting_general.html:208 | |||
|
144 | msgid "No threads exist. Create the first one!" | |||
|
145 | msgstr "Нет тем. Создайте первую!" | |||
|
146 | ||||
|
147 | #: templates/boards/archive.html:138 templates/boards/posting_general.html:235 | |||
|
148 | msgid "Pages:" | |||
|
149 | msgstr "Страницы: " | |||
|
150 | ||||
115 | #: templates/boards/authors.html:6 templates/boards/authors.html.py:12 |
|
151 | #: templates/boards/authors.html:6 templates/boards/authors.html.py:12 | |
116 | msgid "Authors" |
|
152 | msgid "Authors" | |
117 | msgstr "Авторы" |
|
153 | msgstr "Авторы" | |
@@ -149,12 +185,16 b' msgstr "\xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8"' | |||||
149 | msgid "Login" |
|
185 | msgid "Login" | |
150 | msgstr "Вход" |
|
186 | msgstr "Вход" | |
151 |
|
187 | |||
152 |
#: templates/boards/base.html:5 |
|
188 | #: templates/boards/base.html:51 | |
|
189 | msgid "Archive" | |||
|
190 | msgstr "Архив" | |||
|
191 | ||||
|
192 | #: templates/boards/base.html:53 | |||
153 | #, python-format |
|
193 | #, python-format | |
154 | msgid "Speed: %(ppd)s posts per day" |
|
194 | msgid "Speed: %(ppd)s posts per day" | |
155 | msgstr "Скорость: %(ppd)s сообщений в день" |
|
195 | msgstr "Скорость: %(ppd)s сообщений в день" | |
156 |
|
196 | |||
157 |
#: templates/boards/base.html:5 |
|
197 | #: templates/boards/base.html:55 | |
158 | msgid "Up" |
|
198 | msgid "Up" | |
159 | msgstr "Вверх" |
|
199 | msgstr "Вверх" | |
160 |
|
200 | |||
@@ -166,52 +206,20 b' msgstr "ID \xd0\xbf\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8f"' | |||||
166 | msgid "Insert your user id above" |
|
206 | msgid "Insert your user id above" | |
167 | msgstr "Вставьте свой ID пользователя выше" |
|
207 | msgstr "Вставьте свой ID пользователя выше" | |
168 |
|
208 | |||
169 | #: templates/boards/post.html:35 templates/boards/posting_general.html:103 |
|
|||
170 | #: templates/boards/thread.html:68 |
|
|||
171 | msgid "Delete" |
|
|||
172 | msgstr "Удалить" |
|
|||
173 |
|
||||
174 | #: templates/boards/post.html:38 templates/boards/posting_general.html:107 |
|
|||
175 | #: templates/boards/thread.html:71 |
|
|||
176 | msgid "Ban IP" |
|
|||
177 | msgstr "Заблокировать IP" |
|
|||
178 |
|
||||
179 | #: templates/boards/post.html:51 templates/boards/posting_general.html:116 |
|
|||
180 | #: templates/boards/posting_general.html:180 templates/boards/thread.html:80 |
|
|||
181 | msgid "Replies" |
|
|||
182 | msgstr "Ответы" |
|
|||
183 |
|
||||
184 | #: templates/boards/posting_general.html:64 |
|
|||
185 | msgid "Previous page" |
|
|||
186 | msgstr "Предыдущая страница" |
|
|||
187 |
|
||||
188 | #: templates/boards/posting_general.html:97 |
|
209 | #: templates/boards/posting_general.html:97 | |
189 | msgid "Reply" |
|
210 | msgid "Reply" | |
190 | msgstr "Ответ" |
|
211 | msgstr "Ответ" | |
191 |
|
212 | |||
192 | #: templates/boards/posting_general.html:125 templates/boards/thread.html:130 |
|
|||
193 | #: templates/boards/thread_gallery.html:52 |
|
|||
194 | msgid "images" |
|
|||
195 | msgstr "изображений" |
|
|||
196 |
|
||||
197 | #: templates/boards/posting_general.html:142 |
|
213 | #: templates/boards/posting_general.html:142 | |
198 | #, python-format |
|
214 | #, python-format | |
199 | msgid "Skipped %(count)s replies. Open thread to see all replies." |
|
215 | msgid "Skipped %(count)s replies. Open thread to see all replies." | |
200 | msgstr "Пропущено %(count)s ответов. Откройте тред, чтобы увидеть все ответы." |
|
216 | msgstr "Пропущено %(count)s ответов. Откройте тред, чтобы увидеть все ответы." | |
201 |
|
217 | |||
202 | #: templates/boards/posting_general.html:203 |
|
|||
203 | msgid "Next page" |
|
|||
204 | msgstr "Следующая страница" |
|
|||
205 |
|
||||
206 | #: templates/boards/posting_general.html:208 |
|
|||
207 | msgid "No threads exist. Create the first one!" |
|
|||
208 | msgstr "Нет тем. Создайте первую!" |
|
|||
209 |
|
||||
210 | #: templates/boards/posting_general.html:214 |
|
218 | #: templates/boards/posting_general.html:214 | |
211 | msgid "Create new thread" |
|
219 | msgid "Create new thread" | |
212 | msgstr "Создать новую тему" |
|
220 | msgstr "Создать новую тему" | |
213 |
|
221 | |||
214 |
#: templates/boards/posting_general.html:218 templates/boards/thread.html:11 |
|
222 | #: templates/boards/posting_general.html:218 templates/boards/thread.html:115 | |
215 | msgid "Post" |
|
223 | msgid "Post" | |
216 | msgstr "Отправить" |
|
224 | msgstr "Отправить" | |
217 |
|
225 | |||
@@ -220,14 +228,10 b' msgid "Tags must be delimited by spaces.' | |||||
220 | msgstr "" |
|
228 | msgstr "" | |
221 | "Теги должны быть разделены пробелами. Текст или изображение обязательны." |
|
229 | "Теги должны быть разделены пробелами. Текст или изображение обязательны." | |
222 |
|
230 | |||
223 |
#: templates/boards/posting_general.html:225 templates/boards/thread.html:11 |
|
231 | #: templates/boards/posting_general.html:225 templates/boards/thread.html:119 | |
224 | msgid "Text syntax" |
|
232 | msgid "Text syntax" | |
225 | msgstr "Синтаксис текста" |
|
233 | msgstr "Синтаксис текста" | |
226 |
|
234 | |||
227 | #: templates/boards/posting_general.html:235 |
|
|||
228 | msgid "Pages:" |
|
|||
229 | msgstr "Страницы: " |
|
|||
230 |
|
||||
231 | #: templates/boards/settings.html:14 |
|
235 | #: templates/boards/settings.html:14 | |
232 | msgid "User:" |
|
236 | msgid "User:" | |
233 | msgstr "Пользователь:" |
|
237 | msgstr "Пользователь:" | |
@@ -260,27 +264,27 b' msgstr "\xd1\x82\xd0\xb5\xd0\xbc"' | |||||
260 | msgid "No tags found." |
|
264 | msgid "No tags found." | |
261 | msgstr "Теги не найдены." |
|
265 | msgstr "Теги не найдены." | |
262 |
|
266 | |||
263 |
#: templates/boards/thread.html: |
|
267 | #: templates/boards/thread.html:19 templates/boards/thread_gallery.html:20 | |
264 | msgid "Normal mode" |
|
268 | msgid "Normal mode" | |
265 | msgstr "Нормальный режим" |
|
269 | msgstr "Нормальный режим" | |
266 |
|
270 | |||
267 |
#: templates/boards/thread.html:2 |
|
271 | #: templates/boards/thread.html:20 templates/boards/thread_gallery.html:21 | |
268 | msgid "Gallery mode" |
|
272 | msgid "Gallery mode" | |
269 | msgstr "Режим галереи" |
|
273 | msgstr "Режим галереи" | |
270 |
|
274 | |||
271 |
#: templates/boards/thread.html: |
|
275 | #: templates/boards/thread.html:28 | |
272 | msgid "posts to bumplimit" |
|
276 | msgid "posts to bumplimit" | |
273 | msgstr "сообщений до бамплимита" |
|
277 | msgstr "сообщений до бамплимита" | |
274 |
|
278 | |||
275 |
#: templates/boards/thread.html:10 |
|
279 | #: templates/boards/thread.html:109 | |
276 | msgid "Reply to thread" |
|
280 | msgid "Reply to thread" | |
277 | msgstr "Ответить в тему" |
|
281 | msgstr "Ответить в тему" | |
278 |
|
282 | |||
279 |
#: templates/boards/thread.html:1 |
|
283 | #: templates/boards/thread.html:137 templates/boards/thread_gallery.html:57 | |
280 | msgid "replies" |
|
284 | msgid "replies" | |
281 | msgstr "ответов" |
|
285 | msgstr "ответов" | |
282 |
|
286 | |||
283 |
#: templates/boards/thread.html:13 |
|
287 | #: templates/boards/thread.html:139 templates/boards/thread_gallery.html:59 | |
284 | msgid "Last update: " |
|
288 | msgid "Last update: " | |
285 | msgstr "Последнее обновление: " |
|
289 | msgstr "Последнее обновление: " | |
286 |
|
290 |
@@ -15,6 +15,8 b' from markupfield.fields import MarkupFie' | |||||
15 | from neboard import settings |
|
15 | from neboard import settings | |
16 | from boards import thumbs |
|
16 | from boards import thumbs | |
17 |
|
17 | |||
|
18 | MAX_TITLE_LENGTH = 50 | |||
|
19 | ||||
18 | APP_LABEL_BOARDS = 'boards' |
|
20 | APP_LABEL_BOARDS = 'boards' | |
19 |
|
21 | |||
20 | CACHE_KEY_PPD = 'ppd' |
|
22 | CACHE_KEY_PPD = 'ppd' | |
@@ -64,7 +66,8 b' class PostManager(models.Manager):' | |||||
64 | thread_new=thread, |
|
66 | thread_new=thread, | |
65 | image=image, |
|
67 | image=image, | |
66 | poster_ip=ip, |
|
68 | poster_ip=ip, | |
67 |
poster_user_agent=UNKNOWN_UA, # TODO Get UA at |
|
69 | poster_user_agent=UNKNOWN_UA, # TODO Get UA at | |
|
70 | # last! | |||
68 | last_edit_time=posting_time, |
|
71 | last_edit_time=posting_time, | |
69 | user=user) |
|
72 | user=user) | |
70 |
|
73 | |||
@@ -111,7 +114,7 b' class PostManager(models.Manager):' | |||||
111 |
|
114 | |||
112 | # TODO Move this method to thread manager |
|
115 | # TODO Move this method to thread manager | |
113 | def get_threads(self, tag=None, page=ALL_PAGES, |
|
116 | def get_threads(self, tag=None, page=ALL_PAGES, | |
114 | order_by='-bump_time'): |
|
117 | order_by='-bump_time', archived=False): | |
115 | if tag: |
|
118 | if tag: | |
116 | threads = tag.threads |
|
119 | threads = tag.threads | |
117 |
|
120 | |||
@@ -120,7 +123,7 b' class PostManager(models.Manager):' | |||||
120 | else: |
|
123 | else: | |
121 | threads = Thread.objects.all() |
|
124 | threads = Thread.objects.all() | |
122 |
|
125 | |||
123 | threads = threads.order_by(order_by) |
|
126 | threads = threads.filter(archived=archived).order_by(order_by) | |
124 |
|
127 | |||
125 | if page != ALL_PAGES: |
|
128 | if page != ALL_PAGES: | |
126 | thread_count = threads.count() |
|
129 | thread_count = threads.count() | |
@@ -134,25 +137,23 b' class PostManager(models.Manager):' | |||||
134 | return threads |
|
137 | return threads | |
135 |
|
138 | |||
136 | # TODO Move this method to thread manager |
|
139 | # TODO Move this method to thread manager | |
137 | def get_thread_page_count(self, tag=None): |
|
140 | def get_thread_page_count(self, tag=None, archived=False): | |
138 | if tag: |
|
141 | if tag: | |
139 | threads = Thread.objects.filter(tags=tag) |
|
142 | threads = Thread.objects.filter(tags=tag) | |
140 | else: |
|
143 | else: | |
141 | threads = Thread.objects.all() |
|
144 | threads = Thread.objects.all() | |
142 |
|
145 | |||
|
146 | threads = threads.filter(archived=archived) | |||
|
147 | ||||
143 | return self._get_page_count(threads.count()) |
|
148 | return self._get_page_count(threads.count()) | |
144 |
|
149 | |||
145 | # TODO Move this method to thread manager |
|
150 | # TODO Move this method to thread manager | |
146 | def _delete_old_threads(self): |
|
151 | def _delete_old_threads(self): | |
147 | """ |
|
152 | """ | |
148 | Preserves maximum thread count. If there are too many threads, |
|
153 | Preserves maximum thread count. If there are too many threads, | |
149 |
|
|
154 | archive the old ones. | |
150 | """ |
|
155 | """ | |
151 |
|
156 | |||
152 | # TODO Move old threads to the archive instead of deleting them. |
|
|||
153 | # Maybe make some 'old' field in the model to indicate the thread |
|
|||
154 | # must not be shown and be able for replying. |
|
|||
155 |
|
||||
156 | threads = self.get_threads() |
|
157 | threads = self.get_threads() | |
157 | thread_count = threads.count() |
|
158 | thread_count = threads.count() | |
158 |
|
159 | |||
@@ -160,7 +161,9 b' class PostManager(models.Manager):' | |||||
160 | num_threads_to_delete = thread_count - settings.MAX_THREAD_COUNT |
|
161 | num_threads_to_delete = thread_count - settings.MAX_THREAD_COUNT | |
161 | old_threads = threads[thread_count - num_threads_to_delete:] |
|
162 | old_threads = threads[thread_count - num_threads_to_delete:] | |
162 |
|
163 | |||
163 |
|
|
164 | for thread in old_threads: | |
|
165 | thread.archived = True | |||
|
166 | thread.save() | |||
164 |
|
167 | |||
165 | def connect_replies(self, post): |
|
168 | def connect_replies(self, post): | |
166 | """ |
|
169 | """ | |
@@ -270,7 +273,7 b' class Post(models.Model):' | |||||
270 | def get_title(self): |
|
273 | def get_title(self): | |
271 | title = self.title |
|
274 | title = self.title | |
272 | if len(title) == 0: |
|
275 | if len(title) == 0: | |
273 |
title = self.text.r |
|
276 | title = self.text.rendered[:MAX_TITLE_LENGTH] | |
274 |
|
277 | |||
275 | return title |
|
278 | return title | |
276 |
|
279 | |||
@@ -294,6 +297,7 b' class Thread(models.Model):' | |||||
294 | last_edit_time = models.DateTimeField() |
|
297 | last_edit_time = models.DateTimeField() | |
295 | replies = models.ManyToManyField('Post', symmetrical=False, null=True, |
|
298 | replies = models.ManyToManyField('Post', symmetrical=False, null=True, | |
296 | blank=True, related_name='tre+') |
|
299 | blank=True, related_name='tre+') | |
|
300 | archived = models.BooleanField(default=False) | |||
297 |
|
301 | |||
298 | def get_tags(self): |
|
302 | def get_tags(self): | |
299 | """ |
|
303 | """ | |
@@ -321,6 +325,9 b' class Thread(models.Model):' | |||||
321 | Check if the thread can be bumped by replying |
|
325 | Check if the thread can be bumped by replying | |
322 | """ |
|
326 | """ | |
323 |
|
327 | |||
|
328 | if self.archived: | |||
|
329 | return False | |||
|
330 | ||||
324 | post_count = self.get_reply_count() |
|
331 | post_count = self.get_reply_count() | |
325 |
|
332 | |||
326 | return post_count < settings.MAX_POSTS_PER_THREAD |
|
333 | return post_count < settings.MAX_POSTS_PER_THREAD |
@@ -43,7 +43,7 b' html {' | |||||
43 | color: #fff380; |
|
43 | color: #fff380; | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | .post, .dead_post, #posts-table { |
|
46 | .post, .dead_post, .archive_post, #posts-table { | |
47 | background: #333; |
|
47 | background: #333; | |
48 | margin: 5px; |
|
48 | margin: 5px; | |
49 | padding: 10px; |
|
49 | padding: 10px; | |
@@ -191,6 +191,10 b' blockquote {' | |||||
191 | background-color: #442222; |
|
191 | background-color: #442222; | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
|
194 | .archive_post { | |||
|
195 | background-color: #000; | |||
|
196 | } | |||
|
197 | ||||
194 | .mark_btn { |
|
198 | .mark_btn { | |
195 | border: 1px solid; |
|
199 | border: 1px solid; | |
196 | min-width: 2ex; |
|
200 | min-width: 2ex; |
@@ -6,11 +6,7 b'' | |||||
6 | {% load static %} |
|
6 | {% load static %} | |
7 |
|
7 | |||
8 | {% block head %} |
|
8 | {% block head %} | |
9 | {% if tag %} |
|
9 | <title>Neboard</title> | |
10 | <title>Neboard - {{ tag.name }}</title> |
|
|||
11 | {% else %} |
|
|||
12 | <title>Neboard</title> |
|
|||
13 | {% endif %} |
|
|||
14 |
|
10 | |||
15 | {% if prev_page %} |
|
11 | {% if prev_page %} | |
16 | <link rel="next" href=" |
|
12 | <link rel="next" href=" | |
@@ -37,21 +33,6 b'' | |||||
37 |
|
33 | |||
38 | {% get_current_language as LANGUAGE_CODE %} |
|
34 | {% get_current_language as LANGUAGE_CODE %} | |
39 |
|
35 | |||
40 | {% if tag %} |
|
|||
41 | <div class="tag_info"> |
|
|||
42 | <h2> |
|
|||
43 | {% if tag in user.fav_tags.all %} |
|
|||
44 | <a href="{% url 'tag_unsubscribe' tag.name %}?next={{ request.path }}" |
|
|||
45 | class="fav">★</a> |
|
|||
46 | {% else %} |
|
|||
47 | <a href="{% url 'tag_subscribe' tag.name %}?next={{ request.path }}" |
|
|||
48 | class="not_fav">★</a> |
|
|||
49 | {% endif %} |
|
|||
50 | #{{ tag.name }} |
|
|||
51 | </h2> |
|
|||
52 | </div> |
|
|||
53 | {% endif %} |
|
|||
54 |
|
||||
55 | {% if threads %} |
|
36 | {% if threads %} | |
56 | {% if prev_page %} |
|
37 | {% if prev_page %} | |
57 | <div class="page_link"> |
|
38 | <div class="page_link"> | |
@@ -68,11 +49,7 b'' | |||||
68 | {% for thread in threads %} |
|
49 | {% for thread in threads %} | |
69 | {% cache 600 thread_short thread.id thread.thread.last_edit_time moderator LANGUAGE_CODE %} |
|
50 | {% cache 600 thread_short thread.id thread.thread.last_edit_time moderator LANGUAGE_CODE %} | |
70 | <div class="thread"> |
|
51 | <div class="thread"> | |
71 | {% if thread.bumpable %} |
|
52 | <div class="post archive_post" id="{{ thread.op.id }}"> | |
72 | <div class="post" id="{{ thread.op.id }}"> |
|
|||
73 | {% else %} |
|
|||
74 | <div class="post dead_post" id="{{ thread.op.id }}"> |
|
|||
75 | {% endif %} |
|
|||
76 | {% if thread.op.image %} |
|
53 | {% if thread.op.image %} | |
77 | <div class="image"> |
|
54 | <div class="image"> | |
78 | <a class="thumb" |
|
55 | <a class="thumb" | |
@@ -91,10 +68,7 b'' | |||||
91 | <span class="title">{{ thread.op.title }}</span> |
|
68 | <span class="title">{{ thread.op.title }}</span> | |
92 | <a class="post_id" href="{% url 'thread' thread.op.id %}" |
|
69 | <a class="post_id" href="{% url 'thread' thread.op.id %}" | |
93 | > ({{ thread.op.id }})</a> |
|
70 | > ({{ thread.op.id }})</a> | |
94 | [{{ thread.op.pub_time }}] |
|
71 | [{{ thread.op.pub_time }}] — [{{ thread.thread.bump_time }}] | |
95 | [<a class="link" href=" |
|
|||
96 | {% url 'thread' thread.op.id %}#form" |
|
|||
97 | >{% trans "Reply" %}</a>] |
|
|||
98 |
|
72 | |||
99 | {% if moderator %} |
|
73 | {% if moderator %} | |
100 | <span class="moderator_info"> |
|
74 | <span class="moderator_info"> | |
@@ -135,59 +109,6 b'' | |||||
135 | {% endif %} |
|
109 | {% endif %} | |
136 | </div> |
|
110 | </div> | |
137 | </div> |
|
111 | </div> | |
138 | {% if thread.last_replies.exists %} |
|
|||
139 | {% if thread.skipped_replies %} |
|
|||
140 | <div class="skipped_replies"> |
|
|||
141 | <a href="{% url 'thread' thread.op.id %}"> |
|
|||
142 | {% blocktrans with count=thread.skipped_replies %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %} |
|
|||
143 | </a> |
|
|||
144 | </div> |
|
|||
145 | {% endif %} |
|
|||
146 | <div class="last-replies"> |
|
|||
147 | {% for post in thread.last_replies %} |
|
|||
148 | {% if thread.bumpable %} |
|
|||
149 | <div class="post" id="{{ post.id }}"> |
|
|||
150 | {% else %} |
|
|||
151 | <div class="post dead_post" id="{{ post.id }}"> |
|
|||
152 | {% endif %} |
|
|||
153 | {% if post.image %} |
|
|||
154 | <div class="image"> |
|
|||
155 | <a class="thumb" |
|
|||
156 | href="{{ post.image.url }}"><img |
|
|||
157 | src=" {{ post.image.url_200x150 }}" |
|
|||
158 | alt="{{ post.id }}" |
|
|||
159 | width="{{ post.image_pre_width }}" |
|
|||
160 | height="{{ post.image_pre_height }}" |
|
|||
161 | data-width="{{ post.image_width }}" |
|
|||
162 | data-height="{{ post.image_height }}"/> |
|
|||
163 | </a> |
|
|||
164 | </div> |
|
|||
165 | {% endif %} |
|
|||
166 | <div class="message"> |
|
|||
167 | <div class="post-info"> |
|
|||
168 | <span class="title">{{ post.title }}</span> |
|
|||
169 | <a class="post_id" href=" |
|
|||
170 | {% url 'thread' thread.op.id %}#{{ post.id }}"> |
|
|||
171 | ({{ post.id }})</a> |
|
|||
172 | [{{ post.pub_time }}] |
|
|||
173 | </div> |
|
|||
174 | {% autoescape off %} |
|
|||
175 | {{ post.text.rendered|truncatewords_html:50 }} |
|
|||
176 | {% endautoescape %} |
|
|||
177 | </div> |
|
|||
178 | {% if post.is_referenced %} |
|
|||
179 | <div class="refmap"> |
|
|||
180 | {% trans "Replies" %}: |
|
|||
181 | {% for ref_post in post.get_sorted_referenced_posts %} |
|
|||
182 | <a href="{% post_url ref_post.id %}">>>{{ ref_post.id }}</a |
|
|||
183 | >{% if not forloop.last %},{% endif %} |
|
|||
184 | {% endfor %} |
|
|||
185 | </div> |
|
|||
186 | {% endif %} |
|
|||
187 | </div> |
|
|||
188 | {% endfor %} |
|
|||
189 | </div> |
|
|||
190 | {% endif %} |
|
|||
191 | </div> |
|
112 | </div> | |
192 | {% endcache %} |
|
113 | {% endcache %} | |
193 | {% endfor %} |
|
114 | {% endfor %} | |
@@ -208,24 +129,6 b'' | |||||
208 | {% trans 'No threads exist. Create the first one!' %}</div> |
|
129 | {% trans 'No threads exist. Create the first one!' %}</div> | |
209 | {% endif %} |
|
130 | {% endif %} | |
210 |
|
131 | |||
211 | <div class="post-form-w"> |
|
|||
212 | <script src="{% static 'js/panel.js' %}"></script> |
|
|||
213 | <div class="post-form"> |
|
|||
214 | <div class="form-title">{% trans "Create new thread" %}</div> |
|
|||
215 | <form enctype="multipart/form-data" method="post">{% csrf_token %} |
|
|||
216 | {{ form.as_div }} |
|
|||
217 | <div class="form-submit"> |
|
|||
218 | <input type="submit" value="{% trans "Post" %}"/> |
|
|||
219 | </div> |
|
|||
220 | </form> |
|
|||
221 | <div> |
|
|||
222 | {% trans 'Tags must be delimited by spaces. Text or image is required.' %} |
|
|||
223 | </div> |
|
|||
224 | <div><a href="{% url "staticpage" name="help" %}"> |
|
|||
225 | {% trans 'Text syntax' %}</a></div> |
|
|||
226 | </div> |
|
|||
227 | </div> |
|
|||
228 |
|
||||
229 | {% endblock %} |
|
132 | {% endblock %} | |
230 |
|
133 | |||
231 | {% block metapanel %} |
|
134 | {% block metapanel %} | |
@@ -239,11 +142,7 b'' | |||||
239 | class="current_page" |
|
142 | class="current_page" | |
240 | {% endifequal %} |
|
143 | {% endifequal %} | |
241 | href=" |
|
144 | href=" | |
242 |
|
|
145 | {% url "archive" page=page %} | |
243 | {% url "tag" tag_name=tag page=page %} |
|
|||
244 | {% else %} |
|
|||
245 | {% url "index" page=page %} |
|
|||
246 | {% endif %} |
|
|||
247 | ">{{ page }}</a> |
|
146 | ">{{ page }}</a> | |
248 | {% if not forloop.last %},{% endif %} |
|
147 | {% if not forloop.last %},{% endif %} | |
249 | {% endfor %} |
|
148 | {% endfor %} |
@@ -48,6 +48,7 b'' | |||||
48 | <div class="navigation_panel"> |
|
48 | <div class="navigation_panel"> | |
49 | {% block metapanel %}{% endblock %} |
|
49 | {% block metapanel %}{% endblock %} | |
50 | [<a href="{% url "login" %}">{% trans 'Login' %}</a>] |
|
50 | [<a href="{% url "login" %}">{% trans 'Login' %}</a>] | |
|
51 | [<a href="{% url "archive" %}">{% trans 'Archive' %}</a>] | |||
51 | {% with ppd=posts_per_day|floatformat:2 %} |
|
52 | {% with ppd=posts_per_day|floatformat:2 %} | |
52 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} |
|
53 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} | |
53 | {% endwith %} |
|
54 | {% endwith %} |
@@ -231,7 +231,7 b'' | |||||
231 | {% block metapanel %} |
|
231 | {% block metapanel %} | |
232 |
|
232 | |||
233 | <span class="metapanel"> |
|
233 | <span class="metapanel"> | |
234 |
<b><a href="{% url "authors" %}">Neboard</a> 1. |
|
234 | <b><a href="{% url "authors" %}">Neboard</a> 1.6 Amon</b> | |
235 | {% trans "Pages:" %}[ |
|
235 | {% trans "Pages:" %}[ | |
236 | {% for page in pages %} |
|
236 | {% for page in pages %} | |
237 | <a |
|
237 | <a |
@@ -6,7 +6,7 b'' | |||||
6 | {% load board %} |
|
6 | {% load board %} | |
7 |
|
7 | |||
8 | {% block head %} |
|
8 | {% block head %} | |
9 | <title>Neboard - {{ thread.get_opening_post.get_title }}</title> |
|
9 | <title>Neboard - {{ thread.get_opening_post.get_title|striptags }}</title> | |
10 | {% endblock %} |
|
10 | {% endblock %} | |
11 |
|
11 | |||
12 | {% block content %} |
|
12 | {% block content %} | |
@@ -33,6 +33,8 b'' | |||||
33 | {% for post in posts %} |
|
33 | {% for post in posts %} | |
34 | {% if bumpable %} |
|
34 | {% if bumpable %} | |
35 | <div class="post" id="{{ post.id }}"> |
|
35 | <div class="post" id="{{ post.id }}"> | |
|
36 | {% elif thread.archived %} | |||
|
37 | <div class="post archive_post" id="{{ post.id }}"> | |||
36 | {% else %} |
|
38 | {% else %} | |
37 | <div class="post dead_post" id="{{ post.id }}"> |
|
39 | <div class="post dead_post" id="{{ post.id }}"> | |
38 | {% endif %} |
|
40 | {% endif %} | |
@@ -56,8 +58,10 b'' | |||||
56 | <a class="post_id" href="#{{ post.id }}"> |
|
58 | <a class="post_id" href="#{{ post.id }}"> | |
57 | ({{ post.id }})</a> |
|
59 | ({{ post.id }})</a> | |
58 | [{{ post.pub_time }}] |
|
60 | [{{ post.pub_time }}] | |
|
61 | {% if not thread.archived %} | |||
59 | [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}') |
|
62 | [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}') | |
60 | ; return false;">>></a>] |
|
63 | ; return false;">>></a>] | |
|
64 | {% endif %} | |||
61 |
|
65 | |||
62 | {% if moderator %} |
|
66 | {% if moderator %} | |
63 | <span class="moderator_info"> |
|
67 | <span class="moderator_info"> | |
@@ -98,6 +102,8 b'' | |||||
98 | </div> |
|
102 | </div> | |
99 | {% endcache %} |
|
103 | {% endcache %} | |
100 |
|
104 | |||
|
105 | {% if not thread.archived %} | |||
|
106 | ||||
101 | <div class="post-form-w"> |
|
107 | <div class="post-form-w"> | |
102 | <script src="{% static 'js/panel.js' %}"></script> |
|
108 | <script src="{% static 'js/panel.js' %}"></script> | |
103 | <div class="form-title">{% trans "Reply to thread" %} #{{ thread.get_opening_post.id }}</div> |
|
109 | <div class="form-title">{% trans "Reply to thread" %} #{{ thread.get_opening_post.id }}</div> | |
@@ -114,7 +120,9 b'' | |||||
114 | </div> |
|
120 | </div> | |
115 | </div> |
|
121 | </div> | |
116 |
|
122 | |||
117 | <script src="{% static 'js/thread_update.js' %}"></script> |
|
123 | <script src="{% static 'js/thread_update.js' %}"></script> | |
|
124 | {% endif %} | |||
|
125 | ||||
118 | <script src="{% static 'js/thread.js' %}"></script> |
|
126 | <script src="{% static 'js/thread.js' %}"></script> | |
119 |
|
127 | |||
120 | {% endspaceless %} |
|
128 | {% endspaceless %} |
@@ -6,7 +6,7 b'' | |||||
6 | {% load board %} |
|
6 | {% load board %} | |
7 |
|
7 | |||
8 | {% block head %} |
|
8 | {% block head %} | |
9 | <title>Neboard - {{ thread.get_opening_post.get_title }}</title> |
|
9 | <title>Neboard - {{ thread.get_opening_post.get_title|striptags }}</title> | |
10 | {% endblock %} |
|
10 | {% endblock %} | |
11 |
|
11 | |||
12 | {% block content %} |
|
12 | {% block content %} |
@@ -14,6 +14,9 b" urlpatterns = patterns(''," | |||||
14 | # /boards/page/ |
|
14 | # /boards/page/ | |
15 | url(r'^page/(?P<page>\w+)/$', views.index, name='index'), |
|
15 | url(r'^page/(?P<page>\w+)/$', views.index, name='index'), | |
16 |
|
16 | |||
|
17 | url(r'^archive/$', views.archive, name='archive'), | |||
|
18 | url(r'^archive/page/(?P<page>\w+)/$', views.archive, name='archive'), | |||
|
19 | ||||
17 | # login page |
|
20 | # login page | |
18 | url(r'^login/$', views.login, name='login'), |
|
21 | url(r'^login/$', views.login, name='login'), | |
19 |
|
22 |
@@ -67,7 +67,7 b' def index(request, page=0):' | |||||
67 | context['current_page'] = int(page) |
|
67 | context['current_page'] = int(page) | |
68 |
|
68 | |||
69 | page_count = Post.objects.get_thread_page_count() |
|
69 | page_count = Post.objects.get_thread_page_count() | |
70 | context['pages'] = range(page_count) |
|
70 | context['pages'] = range(page_count) if page_count > 0 else [0] | |
71 | page = int(page) |
|
71 | page = int(page) | |
72 | if page < page_count - 1: |
|
72 | if page < page_count - 1: | |
73 | context['next_page'] = str(page + 1) |
|
73 | context['next_page'] = str(page + 1) | |
@@ -78,6 +78,28 b' def index(request, page=0):' | |||||
78 | context) |
|
78 | context) | |
79 |
|
79 | |||
80 |
|
80 | |||
|
81 | def archive(request, page=0): | |||
|
82 | context = _init_default_context(request) | |||
|
83 | ||||
|
84 | threads = [] | |||
|
85 | for thread_to_show in Post.objects.get_threads(page=int(page), | |||
|
86 | archived=True): | |||
|
87 | threads.append(_get_template_thread(thread_to_show)) | |||
|
88 | ||||
|
89 | context['threads'] = threads | |||
|
90 | context['current_page'] = int(page) | |||
|
91 | ||||
|
92 | page_count = Post.objects.get_thread_page_count(archived=True) | |||
|
93 | context['pages'] = range(page_count) if page_count > 0 else [0] | |||
|
94 | page = int(page) | |||
|
95 | if page < page_count - 1: | |||
|
96 | context['next_page'] = str(page + 1) | |||
|
97 | if page > 0: | |||
|
98 | context['prev_page'] = str(page - 1) | |||
|
99 | ||||
|
100 | return render(request, 'boards/archive.html', context) | |||
|
101 | ||||
|
102 | ||||
81 | @transaction.atomic |
|
103 | @transaction.atomic | |
82 | def _new_post(request, form, opening_post=None): |
|
104 | def _new_post(request, form, opening_post=None): | |
83 | """Add a new post (in thread or as a reply).""" |
|
105 | """Add a new post (in thread or as a reply).""" | |
@@ -184,7 +206,7 b' def thread(request, post_id, mode=MODE_N' | |||||
184 | kwargs = {} |
|
206 | kwargs = {} | |
185 |
|
207 | |||
186 | opening_post = get_object_or_404(Post, id=post_id) |
|
208 | opening_post = get_object_or_404(Post, id=post_id) | |
187 | if request.method == 'POST': |
|
209 | if request.method == 'POST' and not opening_post.thread_new.archived: | |
188 | form = postFormClass(request.POST, request.FILES, |
|
210 | form = postFormClass(request.POST, request.FILES, | |
189 | error_class=PlainErrorList, **kwargs) |
|
211 | error_class=PlainErrorList, **kwargs) | |
190 | form.session = request.session |
|
212 | form.session = request.session |
@@ -4,4 +4,7 b' styles.' | |||||
4 | * Showing notification in page title when new posts are loaded into the open |
|
4 | * Showing notification in page title when new posts are loaded into the open | |
5 | thread. |
|
5 | thread. | |
6 | * Thread moderation fixes |
|
6 | * Thread moderation fixes | |
7 | * Added new gallery with search links and image metadata No newline at end of file |
|
7 | * Added new gallery with search links and image metadata | |
|
8 | ||||
|
9 | # 1.6 Amon # | |||
|
10 | * Deleted threads are moved to archive instead of permanent delete No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now