Show More
@@ -5,6 +5,7 b' from datetime import time as dtime' | |||
|
5 | 5 | |
|
6 | 6 | from django.db import models, transaction |
|
7 | 7 | from django.utils import timezone |
|
8 | from django.dispatch import Signal | |
|
8 | 9 | |
|
9 | 10 | import boards |
|
10 | 11 | |
@@ -27,6 +28,9 b' POSTS_PER_DAY_RANGE = 7' | |||
|
27 | 28 | NO_IP = '0.0.0.0' |
|
28 | 29 | |
|
29 | 30 | |
|
31 | post_import_deps = Signal() | |
|
32 | ||
|
33 | ||
|
30 | 34 | class PostManager(models.Manager): |
|
31 | 35 | @transaction.atomic |
|
32 | 36 | def create_post(self, title: str, text: str, file=None, thread=None, |
@@ -155,6 +159,11 b' class PostManager(models.Manager):' | |||
|
155 | 159 | |
|
156 | 160 | post.threads.add(thread) |
|
157 | 161 | |
|
162 | url_to_post = '[post]{}[/post]'.format(str(global_id)) | |
|
163 | replies = self.filter(text__contains=url_to_post) | |
|
164 | for reply in replies: | |
|
165 | post_import_deps.send(reply.__class__) | |
|
166 | ||
|
158 | 167 | @transaction.atomic |
|
159 | 168 | def update_post(self, post, title: str, text: str, pub_time: str, |
|
160 | 169 | tags=list(), files=list(), tripcode=None, version=1): |
@@ -2,8 +2,9 b' import re' | |||
|
2 | 2 | from boards.mdx_neboard import get_parser |
|
3 | 3 | |
|
4 | 4 | from boards.models import Post, GlobalId |
|
5 | from boards.models.post import REGEX_NOTIFICATION | |
|
6 | from boards.models.post import REGEX_REPLY, REGEX_GLOBAL_REPLY | |
|
5 | from boards.models.post import REGEX_NOTIFICATION, REGEX_REPLY,\ | |
|
6 | REGEX_GLOBAL_REPLY | |
|
7 | from boards.models.post.manager import post_import_deps | |
|
7 | 8 | from boards.models.user import Notification |
|
8 | 9 | from django.db.models.signals import post_save, pre_save, pre_delete, \ |
|
9 | 10 | post_delete |
@@ -30,6 +31,7 b' def connect_replies(instance, **kwargs):' | |||
|
30 | 31 | |
|
31 | 32 | |
|
32 | 33 | @receiver(post_save, sender=Post) |
|
34 | @receiver(post_import_deps, sender=Post) | |
|
33 | 35 | def connect_global_replies(instance, **kwargs): |
|
34 | 36 | for reply_number in re.finditer(REGEX_GLOBAL_REPLY, instance.get_raw_text()): |
|
35 | 37 | key_type = reply_number.group(1) |
@@ -56,7 +58,8 b' def connect_notifications(instance, **kw' | |||
|
56 | 58 | |
|
57 | 59 | |
|
58 | 60 | @receiver(pre_save, sender=Post) |
|
59 | def preparse_text(instance, **kwargs): | |
|
61 | @receiver(post_import_deps, sender=Post) | |
|
62 | def parse_text(instance, **kwargs): | |
|
60 | 63 | instance._text_rendered = get_parser().parse(instance.get_raw_text()) |
|
61 | 64 | |
|
62 | 65 |
General Comments 0
You need to be logged in to leave comments.
Login now