##// END OF EJS Templates
Merged with BB
Pavel Ryapolov -
r297:da4642af merge default
parent child Browse files
Show More
@@ -0,0 +1,78 b''
1 # -*- coding: utf-8 -*-
2 import 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 M2M table for field referenced_posts on 'Post'
12 m2m_table_name = db.shorten_name(u'boards_post_referenced_posts')
13 db.create_table(m2m_table_name, (
14 ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
15 ('from_post', models.ForeignKey(orm[u'boards.post'], null=False)),
16 ('to_post', models.ForeignKey(orm[u'boards.post'], null=False))
17 ))
18 db.create_unique(m2m_table_name, ['from_post_id', 'to_post_id'])
19
20
21 def backwards(self, orm):
22 # Removing M2M table for field referenced_posts on 'Post'
23 db.delete_table(db.shorten_name(u'boards_post_referenced_posts'))
24
25
26 models = {
27 u'boards.ban': {
28 'Meta': {'object_name': 'Ban'},
29 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
30 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'})
31 },
32 u'boards.post': {
33 'Meta': {'object_name': 'Post'},
34 '_text_rendered': ('django.db.models.fields.TextField', [], {}),
35 'bump_time': ('django.db.models.fields.DateTimeField', [], {}),
36 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
37 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}),
38 'image_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
39 'image_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
40 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}),
41 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}),
42 'poster_user_agent': ('django.db.models.fields.TextField', [], {}),
43 'pub_time': ('django.db.models.fields.DateTimeField', [], {}),
44 'referenced_posts': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'rfp+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}),
45 'replies': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'re+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}),
46 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}),
47 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}),
48 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}),
49 'thread': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.Post']", 'null': 'True'}),
50 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
51 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.User']", 'null': 'True'})
52 },
53 u'boards.setting': {
54 'Meta': {'object_name': 'Setting'},
55 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
56 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
57 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['boards.User']"}),
58 'value': ('django.db.models.fields.CharField', [], {'max_length': '50'})
59 },
60 u'boards.tag': {
61 'Meta': {'object_name': 'Tag'},
62 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
63 'linked': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['boards.Tag']", 'null': 'True', 'blank': 'True'}),
64 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
65 'threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'tag+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"})
66 },
67 u'boards.user': {
68 'Meta': {'object_name': 'User'},
69 'fav_tags': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['boards.Tag']", 'null': 'True', 'blank': 'True'}),
70 'fav_threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}),
71 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
72 'rank': ('django.db.models.fields.IntegerField', [], {}),
73 'registration_time': ('django.db.models.fields.DateTimeField', [], {}),
74 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '50'})
75 }
76 }
77
78 complete_apps = ['boards'] No newline at end of file
@@ -0,0 +1,15 b''
1 """
2 Maintenance script for neboard imageboard. Use this to update data after
3 migrations etc.
4 """
5
6 from boards.models import Post
7 from boards import views
8
9 def update_posts():
10 for post in Post.objects.all():
11 print 'Updating post #' + str(post.id)
12
13 post.save()
14
15 Post.objects.connect_replies(post)
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: 2013-10-21 21:13+0300\n"
10 "POT-Creation-Date: 2013-10-24 16:06+0300\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"
@@ -35,22 +35,22 b' msgid "designer"'
35 msgstr "дизайнер"
35 msgstr "дизайнер"
36
36
37 #: forms.py:51 templates/boards/posting_general.html:135
37 #: forms.py:51 templates/boards/posting_general.html:135
38 #: templates/boards/thread.html:90
38 #: templates/boards/thread.html:100
39 msgid "Title"
39 msgid "Title"
40 msgstr "Заголовок"
40 msgstr "Заголовок"
41
41
42 #: forms.py:53 templates/boards/posting_general.html:150
42 #: forms.py:53 templates/boards/posting_general.html:150
43 #: templates/boards/thread.html:105
43 #: templates/boards/thread.html:115
44 msgid "Text"
44 msgid "Text"
45 msgstr "Текст"
45 msgstr "Текст"
46
46
47 #: forms.py:54 templates/boards/posting_general.html:155
47 #: forms.py:54 templates/boards/posting_general.html:155
48 #: templates/boards/thread.html:110
48 #: templates/boards/thread.html:120
49 msgid "Image"
49 msgid "Image"
50 msgstr "Изображение"
50 msgstr "Изображение"
51
51
52 #: forms.py:57 templates/boards/posting_general.html:165
52 #: forms.py:57 templates/boards/posting_general.html:165
53 #: templates/boards/thread.html:115
53 #: templates/boards/thread.html:125
54 msgid "e-mail"
54 msgid "e-mail"
55 msgstr ""
55 msgstr ""
56
56
@@ -81,7 +81,7 b' msgstr "\xd0\x9f\xd0\xbe\xd0\xb4\xd0\xbe\xd0\xb6\xd0\xb4\xd0\xb8\xd1\x82\xd0\xb5 %s \xd1\x81\xd0\xb5\xd0\xba\xd1\x83\xd0\xbd\xd0\xb4 \xd0\xbf\xd0\xbe\xd1\x81\xd0\xbb\xd0\xb5 \xd0\xbf\xd0\xbe\xd1\x81\xd0\xbb\xd0\xb5\xd0\xb4\xd0\xbd\xd0\xb5\xd0\xb3\xd0\xbe \xd0\xbf\xd0\xbe\xd1\x81\xd1\x82\xd0\xb8\xd0\xbd\xd0\xb3\xd0\xb0"'
81 #: forms.py:140 templates/boards/post.html:39
81 #: forms.py:140 templates/boards/post.html:39
82 #: templates/boards/posting_general.html:77
82 #: templates/boards/posting_general.html:77
83 #: templates/boards/posting_general.html:160 templates/boards/tags.html:7
83 #: templates/boards/posting_general.html:160 templates/boards/tags.html:7
84 #: templates/boards/thread.html:70 templates/boards/rss/post.html:10
84 #: templates/boards/thread.html:80 templates/boards/rss/post.html:10
85 msgid "Tags"
85 msgid "Tags"
86 msgstr "Теги"
86 msgstr "Теги"
87
87
@@ -118,19 +118,19 b' msgstr "\xd0\x9d\xd0\xb5 \xd0\xbd\xd0\xb0\xd0\xb9\xd0\xb4\xd0\xb5\xd0\xbd\xd0\xbe"'
118 msgid "This page does not exist"
118 msgid "This page does not exist"
119 msgstr "Этой страницы не существует"
119 msgstr "Этой страницы не существует"
120
120
121 #: templates/boards/authors.html:6
121 #: templates/boards/authors.html:6 templates/boards/authors.html.py:12
122 msgid "Authors"
122 msgid "Authors"
123 msgstr "Авторы"
123 msgstr "Авторы"
124
124
125 #: templates/boards/authors.html:24
125 #: templates/boards/authors.html:25
126 msgid "Distributed under the"
126 msgid "Distributed under the"
127 msgstr "Распространяется под"
127 msgstr "Распространяется под"
128
128
129 #: templates/boards/authors.html:26
129 #: templates/boards/authors.html:27
130 msgid "license"
130 msgid "license"
131 msgstr "лицензией"
131 msgstr "лицензией"
132
132
133 #: templates/boards/authors.html:28
133 #: templates/boards/authors.html:29
134 msgid "Repository"
134 msgid "Repository"
135 msgstr "Репозиторий"
135 msgstr "Репозиторий"
136
136
@@ -172,12 +172,12 b' msgid "Post image"'
172 msgstr "Изображение сообщения"
172 msgstr "Изображение сообщения"
173
173
174 #: templates/boards/post.html:26 templates/boards/posting_general.html:62
174 #: templates/boards/post.html:26 templates/boards/posting_general.html:62
175 #: templates/boards/thread.html:57
175 #: templates/boards/thread.html:59
176 msgid "Delete"
176 msgid "Delete"
177 msgstr "Удалить"
177 msgstr "Удалить"
178
178
179 #: templates/boards/post.html:29 templates/boards/posting_general.html:65
179 #: templates/boards/post.html:29 templates/boards/posting_general.html:65
180 #: templates/boards/thread.html:60
180 #: templates/boards/thread.html:62
181 msgid "Ban IP"
181 msgid "Ban IP"
182 msgstr "Заблокировать IP"
182 msgstr "Заблокировать IP"
183
183
@@ -189,11 +189,11 b' msgstr "\xd0\xa2\xd0\xb5\xd0\xb3: "'
189 msgid "Reply"
189 msgid "Reply"
190 msgstr "Ответ"
190 msgstr "Ответ"
191
191
192 #: templates/boards/posting_general.html:74 templates/boards/thread.html:143
192 #: templates/boards/posting_general.html:74 templates/boards/thread.html:153
193 msgid "replies"
193 msgid "replies"
194 msgstr "ответов"
194 msgstr "ответов"
195
195
196 #: templates/boards/posting_general.html:75 templates/boards/thread.html:144
196 #: templates/boards/posting_general.html:75 templates/boards/thread.html:154
197 msgid "images"
197 msgid "images"
198 msgstr "изображений"
198 msgstr "изображений"
199
199
@@ -205,31 +205,31 b' msgstr "\xd0\x9d\xd0\xb5\xd1\x82 \xd1\x82\xd0\xb5\xd0\xbc. \xd0\xa1\xd0\xbe\xd0\xb7\xd0\xb4\xd0\xb0\xd0\xb9\xd1\x82\xd0\xb5 \xd0\xbf\xd0\xb5\xd1\x80\xd0\xb2\xd1\x83\xd1\x8e!"'
205 msgid "Create new thread"
205 msgid "Create new thread"
206 msgstr "Создать новую тему"
206 msgstr "Создать новую тему"
207
207
208 #: templates/boards/posting_general.html:140 templates/boards/thread.html:95
208 #: templates/boards/posting_general.html:140 templates/boards/thread.html:105
209 msgid "Formatting"
209 msgid "Formatting"
210 msgstr "Форматирование"
210 msgstr "Форматирование"
211
211
212 #: templates/boards/posting_general.html:142 templates/boards/thread.html:97
212 #: templates/boards/posting_general.html:142 templates/boards/thread.html:107
213 msgid "quote"
213 msgid "quote"
214 msgstr "цитата"
214 msgstr "цитата"
215
215
216 #: templates/boards/posting_general.html:143 templates/boards/thread.html:98
216 #: templates/boards/posting_general.html:143 templates/boards/thread.html:108
217 msgid "italic"
217 msgid "italic"
218 msgstr "курсив"
218 msgstr "курсив"
219
219
220 #: templates/boards/posting_general.html:144 templates/boards/thread.html:99
220 #: templates/boards/posting_general.html:144 templates/boards/thread.html:109
221 msgid "bold"
221 msgid "bold"
222 msgstr "полужирный"
222 msgstr "полужирный"
223
223
224 #: templates/boards/posting_general.html:145 templates/boards/thread.html:100
224 #: templates/boards/posting_general.html:145 templates/boards/thread.html:110
225 msgid "spoiler"
225 msgid "spoiler"
226 msgstr "спойлер"
226 msgstr "спойлер"
227
227
228 #: templates/boards/posting_general.html:146 templates/boards/thread.html:101
228 #: templates/boards/posting_general.html:146 templates/boards/thread.html:111
229 msgid "comment"
229 msgid "comment"
230 msgstr "комментарий"
230 msgstr "комментарий"
231
231
232 #: templates/boards/posting_general.html:178 templates/boards/thread.html:129
232 #: templates/boards/posting_general.html:178 templates/boards/thread.html:139
233 msgid "Post"
233 msgid "Post"
234 msgstr "Отправить"
234 msgstr "Отправить"
235
235
@@ -238,7 +238,7 b' msgid "Tags must be delimited by spaces.'
238 msgstr ""
238 msgstr ""
239 "Теги должны быть разделены пробелами. Текст или изображение обязательны."
239 "Теги должны быть разделены пробелами. Текст или изображение обязательны."
240
240
241 #: templates/boards/posting_general.html:183 templates/boards/thread.html:131
241 #: templates/boards/posting_general.html:183 templates/boards/thread.html:141
242 msgid "Text syntax"
242 msgid "Text syntax"
243 msgstr "Синтаксис текста"
243 msgstr "Синтаксис текста"
244
244
@@ -270,7 +270,7 b' msgstr "\xd0\x9f\xd0\xbe\xd1\x81\xd0\xbb\xd0\xb5\xd0\xb4\xd0\xbd\xd0\xb8\xd0\xb9 \xd0\xb4\xd0\xbe\xd1\x81\xd1\x82\xd1\x83\xd0\xbf: "'
270 msgid "Save"
270 msgid "Save"
271 msgstr "Сохранить"
271 msgstr "Сохранить"
272
272
273 #: templates/boards/tags.html:17
273 #: templates/boards/tags.html:24
274 msgid "threads"
274 msgid "threads"
275 msgstr "тем"
275 msgstr "тем"
276
276
@@ -278,15 +278,19 b' msgstr "\xd1\x82\xd0\xb5\xd0\xbc"'
278 msgid "No tags found."
278 msgid "No tags found."
279 msgstr "Теги не найдены."
279 msgstr "Теги не найдены."
280
280
281 #: templates/boards/thread.html:22
281 #: templates/boards/thread.html:24
282 msgid "posts to bumplimit"
282 msgid "posts to bumplimit"
283 msgstr "сообщений до бамплимита"
283 msgstr "сообщений до бамплимита"
284
284
285 #: templates/boards/thread.html:87
285 #: templates/boards/thread.html:71
286 msgid "Replies"
287 msgstr "Ответы"
288
289 #: templates/boards/thread.html:97
286 msgid "Reply to thread"
290 msgid "Reply to thread"
287 msgstr "Ответить в тему"
291 msgstr "Ответить в тему"
288
292
289 #: templates/boards/thread.html:145
293 #: templates/boards/thread.html:155
290 msgid "Last update: "
294 msgid "Last update: "
291 msgstr "Последнее обновление: "
295 msgstr "Последнее обновление: "
292
296
@@ -12,6 +12,8 b' from markupfield.fields import MarkupFie'
12 from neboard import settings
12 from neboard import settings
13 import thumbs
13 import thumbs
14
14
15 import re
16
15 IMAGE_THUMB_SIZE = (200, 150)
17 IMAGE_THUMB_SIZE = (200, 150)
16
18
17 TITLE_MAX_LENGTH = 50
19 TITLE_MAX_LENGTH = 50
@@ -28,10 +30,12 b" FILE_EXTENSION_DELIMITER = '.'"
28
30
29 RANK_ADMIN = 0
31 RANK_ADMIN = 0
30 RANK_MODERATOR = 10
32 RANK_MODERATOR = 10
31 RANK_USER = 100 \
33 RANK_USER = 100
32
34
33 SETTING_MODERATE = "moderate"
35 SETTING_MODERATE = "moderate"
34
36
37 REGEX_REPLY = re.compile('>>(\d+)')
38
35
39
36 class PostManager(models.Manager):
40 class PostManager(models.Manager):
37
41
@@ -61,6 +65,8 b' class PostManager(models.Manager):'
61 else:
65 else:
62 self._delete_old_threads()
66 self._delete_old_threads()
63
67
68 self.connect_replies(post)
69
64 return post
70 return post
65
71
66 def delete_post(self, post):
72 def delete_post(self, post):
@@ -147,6 +153,15 b' class PostManager(models.Manager):'
147
153
148 map(self.delete_post, old_threads)
154 map(self.delete_post, old_threads)
149
155
156 def connect_replies(self, post):
157 """Connect replies to a post to show them as a refmap"""
158
159 for reply_number in re.finditer(REGEX_REPLY, post.text.raw):
160 id = reply_number.group(1)
161 ref_post = self.filter(id=id)
162 if ref_post.count() > 0:
163 ref_post[0].referenced_posts.add(post)
164
150
165
151 class TagManager(models.Manager):
166 class TagManager(models.Manager):
152
167
@@ -248,6 +263,8 b' class Post(models.Model):'
248
263
249 replies = models.ManyToManyField('Post', symmetrical=False, null=True,
264 replies = models.ManyToManyField('Post', symmetrical=False, null=True,
250 blank=True, related_name='re+')
265 blank=True, related_name='re+')
266 referenced_posts = models.ManyToManyField('Post', symmetrical=False, null=True,
267 blank=True, related_name='rfp+')
251
268
252 def __unicode__(self):
269 def __unicode__(self):
253 return '#' + str(self.id) + ' ' + self.title + ' (' + \
270 return '#' + str(self.id) + ' ' + self.title + ' (' + \
@@ -5,9 +5,9 b''
5 });
5 });
6
6
7 addImgPreview();
7 addImgPreview();
8 addRefLinkMap();
9
8
10 // TODO Rewrite popups module and reenable it
9 // TODO Rewrite popups module and reenable it
11 //addPopups();
10 //addPopups();
11
12 addMarkPanel();
12 addMarkPanel();
13 });
13 });
@@ -52,5 +52,4 b' function addQuickReply(postId) {'
52
52
53 $(document).ready(function(){
53 $(document).ready(function(){
54 addGalleryPanel();
54 addGalleryPanel();
55 addRefLinkMap();
56 });
55 });
@@ -25,7 +25,6 b''
25 <script src="{% static 'js/jquery-ui-1.10.3.custom.min.js' %}"></script>
25 <script src="{% static 'js/jquery-ui-1.10.3.custom.min.js' %}"></script>
26 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
26 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
27 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
27 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
28 <script src="{% static 'js/refmaps.js' %}"></script>
29 <script src="{% static 'js/panel.js' %}"></script>
28 <script src="{% static 'js/panel.js' %}"></script>
30 <script src="{% static 'js/popup.js' %}"></script>
29 <script src="{% static 'js/popup.js' %}"></script>
31 <script src="{% static 'js/image.js' %}"></script>
30 <script src="{% static 'js/image.js' %}"></script>
@@ -83,6 +83,14 b''
83 </span>
83 </span>
84 {% endif %}
84 {% endif %}
85 </div>
85 </div>
86 {% if thread.thread.referenced_posts.all %}
87 <div class="refmap">
88 {% trans "Replies" %}:
89 {% for ref_post in thread.thread.referenced_posts.all %}
90 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
91 {% endfor %}
92 </div>
93 {% endif %}
86 </div>
94 </div>
87 {% if thread.thread.get_last_replies.exists %}
95 {% if thread.thread.get_last_replies.exists %}
88 <div class="last-replies">
96 <div class="last-replies">
@@ -115,6 +123,14 b''
115 {{ post.text.rendered|truncatewords_html:50 }}
123 {{ post.text.rendered|truncatewords_html:50 }}
116 {% endautoescape %}
124 {% endautoescape %}
117 </div>
125 </div>
126 {% if post.referenced_posts.all %}
127 <div class="refmap">
128 {% trans "Replies" %}:
129 {% for ref_post in post.referenced_posts.all %}
130 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
131 {% endfor %}
132 </div>
133 {% endif %}
118 </div>
134 </div>
119 {% endfor %}
135 {% endfor %}
120 </div>
136 </div>
@@ -66,6 +66,14 b''
66 {% autoescape off %}
66 {% autoescape off %}
67 {{ post.text.rendered }}
67 {{ post.text.rendered }}
68 {% endautoescape %}
68 {% endautoescape %}
69 {% if post.referenced_posts.all %}
70 <div class="refmap">
71 {% trans "Replies" %}:
72 {% for ref_post in post.referenced_posts.all %}
73 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
74 {% endfor %}
75 </div>
76 {% endif %}
69 </div>
77 </div>
70 {% if post.id == posts.0.id %}
78 {% if post.id == posts.0.id %}
71 <div class="metadata">
79 <div class="metadata">
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now