Show More
@@ -2,14 +2,21 b'' | |||||
2 | from __future__ import unicode_literals |
|
2 | from __future__ import unicode_literals | |
3 |
|
3 | |||
4 | from django.db import migrations |
|
4 | from django.db import migrations | |
5 | from boards.models import Post |
|
|||
6 |
|
5 | |||
7 |
|
6 | |||
8 | class Migration(migrations.Migration): |
|
7 | class Migration(migrations.Migration): | |
9 |
|
8 | |||
10 |
def re |
|
9 | def rebuild_refmap(apps, schema_editor): | |
|
10 | Post = apps.get_model('boards', 'Post') | |||
11 | for post in Post.objects.all(): |
|
11 | for post in Post.objects.all(): | |
12 |
|
|
12 | refposts = list() | |
|
13 | for refpost in post.referenced_posts.all(): | |||
|
14 | result = '<a href="{}">>>{}</a>'.format(refpost.get_absolute_url(), | |||
|
15 | self.id) | |||
|
16 | if refpost.is_opening(): | |||
|
17 | result = '<b>{}</b>'.format(result) | |||
|
18 | refposts += result | |||
|
19 | post.refmap = ', '.join(refposts) | |||
13 | post.save(update_fields=['refmap']) |
|
20 | post.save(update_fields=['refmap']) | |
14 |
|
21 | |||
15 | dependencies = [ |
|
22 | dependencies = [ | |
@@ -17,5 +24,5 b' class Migration(migrations.Migration):' | |||||
17 | ] |
|
24 | ] | |
18 |
|
25 | |||
19 | operations = [ |
|
26 | operations = [ | |
20 |
migrations.RunPython(re |
|
27 | migrations.RunPython(rebuild_refmap), | |
21 | ] |
|
28 | ] |
@@ -72,8 +72,9 b' class ThreadManager(models.Manager):' | |||||
72 | new_post_count=Count('multi_replies')) |
|
72 | new_post_count=Count('multi_replies')) | |
73 |
|
73 | |||
74 | def get_new_post_count(self, datas): |
|
74 | def get_new_post_count(self, datas): | |
75 |
|
|
75 | new_posts = self.get_new_posts(datas) | |
76 |
|
|
76 | return new_posts.aggregate(total_count=Count('multi_replies'))\ | |
|
77 | ['total_count'] if new_posts else 0 | |||
77 |
|
78 | |||
78 |
|
79 | |||
79 | def get_thread_max_posts(): |
|
80 | def get_thread_max_posts(): | |
@@ -224,7 +225,7 b' class Thread(models.Model):' | |||||
224 | def update_posts_time(self, exclude_posts=None): |
|
225 | def update_posts_time(self, exclude_posts=None): | |
225 | last_edit_time = self.last_edit_time |
|
226 | last_edit_time = self.last_edit_time | |
226 |
|
227 | |||
227 |
for post in self. |
|
228 | for post in self.multi_replies.all(): | |
228 | if exclude_posts is None or post not in exclude_posts: |
|
229 | if exclude_posts is None or post not in exclude_posts: | |
229 | # Manual update is required because uids are generated on save |
|
230 | # Manual update is required because uids are generated on save | |
230 | post.last_edit_time = last_edit_time |
|
231 | post.last_edit_time = last_edit_time |
General Comments 0
You need to be logged in to leave comments.
Login now