Show More
@@ -23,47 +23,50 b' THUMB_SIZES = ((200, 150),)' | |||
|
23 | 23 | |
|
24 | 24 | @receiver(post_save, sender=Post) |
|
25 | 25 | def connect_replies(instance, **kwargs): |
|
26 | for reply_number in re.finditer(REGEX_REPLY, instance.get_raw_text()): | |
|
27 | post_id = reply_number.group(1) | |
|
26 | if not kwargs['update_fields']: | |
|
27 | for reply_number in re.finditer(REGEX_REPLY, instance.get_raw_text()): | |
|
28 | post_id = reply_number.group(1) | |
|
28 | 29 | |
|
29 | try: | |
|
30 | referenced_post = Post.objects.get(id=post_id) | |
|
30 | try: | |
|
31 | referenced_post = Post.objects.get(id=post_id) | |
|
31 | 32 | |
|
32 | if not referenced_post.referenced_posts.filter( | |
|
33 | id=instance.id).exists(): | |
|
34 | referenced_post.referenced_posts.add(instance) | |
|
35 | referenced_post.last_edit_time = instance.pub_time | |
|
36 | referenced_post.build_refmap() | |
|
37 | referenced_post.save(update_fields=['refmap', 'last_edit_time']) | |
|
38 | except Post.DoesNotExist: | |
|
39 | pass | |
|
33 | if not referenced_post.referenced_posts.filter( | |
|
34 | id=instance.id).exists(): | |
|
35 | referenced_post.referenced_posts.add(instance) | |
|
36 | referenced_post.last_edit_time = instance.pub_time | |
|
37 | referenced_post.build_refmap() | |
|
38 | referenced_post.save(update_fields=['refmap', 'last_edit_time']) | |
|
39 | except Post.DoesNotExist: | |
|
40 | pass | |
|
40 | 41 | |
|
41 | 42 | |
|
42 | 43 | @receiver(post_save, sender=Post) |
|
43 | 44 | @receiver(post_import_deps, sender=Post) |
|
44 | 45 | def connect_global_replies(instance, **kwargs): |
|
45 | for reply_number in re.finditer(REGEX_GLOBAL_REPLY, instance.get_raw_text()): | |
|
46 | key_type = reply_number.group(1) | |
|
47 |
key = reply_number.group( |
|
|
48 |
|
|
|
46 | if not kwargs['update_fields']: | |
|
47 | for reply_number in re.finditer(REGEX_GLOBAL_REPLY, instance.get_raw_text()): | |
|
48 | key_type = reply_number.group(1) | |
|
49 | key = reply_number.group(2) | |
|
50 | local_id = reply_number.group(3) | |
|
49 | 51 | |
|
50 | try: | |
|
51 | global_id = GlobalId.objects.get(key_type=key_type, key=key, | |
|
52 | local_id=local_id) | |
|
53 | referenced_post = Post.objects.get(global_id=global_id) | |
|
54 | referenced_post.referenced_posts.add(instance) | |
|
55 | referenced_post.last_edit_time = instance.pub_time | |
|
56 | referenced_post.build_refmap() | |
|
57 | referenced_post.save(update_fields=['refmap', 'last_edit_time']) | |
|
58 | except (GlobalId.DoesNotExist, Post.DoesNotExist): | |
|
59 | pass | |
|
52 | try: | |
|
53 | global_id = GlobalId.objects.get(key_type=key_type, key=key, | |
|
54 | local_id=local_id) | |
|
55 | referenced_post = Post.objects.get(global_id=global_id) | |
|
56 | referenced_post.referenced_posts.add(instance) | |
|
57 | referenced_post.last_edit_time = instance.pub_time | |
|
58 | referenced_post.build_refmap() | |
|
59 | referenced_post.save(update_fields=['refmap', 'last_edit_time']) | |
|
60 | except (GlobalId.DoesNotExist, Post.DoesNotExist): | |
|
61 | pass | |
|
60 | 62 | |
|
61 | 63 | |
|
62 | 64 | @receiver(post_save, sender=Post) |
|
63 | 65 | def connect_notifications(instance, **kwargs): |
|
64 | for reply_number in re.finditer(REGEX_NOTIFICATION, instance.get_raw_text()): | |
|
65 | user_name = reply_number.group(1).lower() | |
|
66 | Notification.objects.get_or_create(name=user_name, post=instance) | |
|
66 | if not kwargs['update_fields']: | |
|
67 | for reply_number in re.finditer(REGEX_NOTIFICATION, instance.get_raw_text()): | |
|
68 | user_name = reply_number.group(1).lower() | |
|
69 | Notification.objects.get_or_create(name=user_name, post=instance) | |
|
67 | 70 | |
|
68 | 71 | |
|
69 | 72 | @receiver(pre_save, sender=Post) |
General Comments 0
You need to be logged in to leave comments.
Login now