diff --git a/boards/admin.py b/boards/admin.py
--- a/boards/admin.py
+++ b/boards/admin.py
@@ -10,7 +10,7 @@ class PostAdmin(admin.ModelAdmin):
list_display = ('id', 'title', 'text', 'poster_ip', 'linked_images')
list_filter = ('pub_time',)
search_fields = ('id', 'title', 'text', 'poster_ip')
- exclude = ('referenced_posts', 'refmap')
+ exclude = ('referenced_posts', 'refmap', 'images')
readonly_fields = ('poster_ip', 'threads', 'thread', 'linked_images',
'attachments', 'uid', 'url', 'pub_time', 'opening')
@@ -38,7 +38,10 @@ class PostAdmin(admin.ModelAdmin):
def linked_images(self, obj: Post):
images = obj.images.all()
- image_urls = ['{}'.format(reverse('admin:%s_%s_change' %(image._meta.app_label, image._meta.model_name), args=[image.id]), image.hash) for image in images]
+ image_urls = [''.format(
+ reverse('admin:%s_%s_change' % (image._meta.app_label,
+ image._meta.model_name),
+ args=[image.id]), image.image.url_200x150) for image in images]
return ', '.join(image_urls)
linked_images.allow_tags = True
diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py
--- a/boards/models/post/__init__.py
+++ b/boards/models/post/__init__.py
@@ -379,3 +379,32 @@ class Post(models.Model, Viewable):
def set_hidden(self, hidden):
self.hidden = hidden
+
+
+# SIGNALS (Maybe move to other module?)
+@receiver(post_save, sender=Post)
+def connect_replies(instance, **kwargs):
+ for reply_number in re.finditer(REGEX_REPLY, instance.get_raw_text()):
+ post_id = reply_number.group(1)
+
+ try:
+ referenced_post = Post.objects.get(id=post_id)
+
+ referenced_post.referenced_posts.add(instance)
+ referenced_post.last_edit_time = instance.pub_time
+ referenced_post.build_refmap()
+ referenced_post.save(update_fields=['refmap', 'last_edit_time'])
+ except ObjectDoesNotExist:
+ pass
+
+
+@receiver(post_save, sender=Post)
+def connect_notifications(instance, **kwargs):
+ for reply_number in re.finditer(REGEX_NOTIFICATION, instance.get_raw_text()):
+ user_name = reply_number.group(1).lower()
+ Notification.objects.get_or_create(name=user_name, post=instance)
+
+
+@receiver(pre_save, sender=Post)
+def preparse_text(instance, **kwargs):
+ instance._text_rendered = get_parser().parse(instance.get_raw_text())
diff --git a/boards/signals.py b/boards/signals.py
--- a/boards/signals.py
+++ b/boards/signals.py
@@ -19,10 +19,11 @@ def connect_replies(instance, **kwargs):
try:
referenced_post = Post.objects.get(id=post_id)
- referenced_post.referenced_posts.add(instance)
- referenced_post.last_edit_time = instance.pub_time
- referenced_post.build_refmap()
- referenced_post.save(update_fields=['refmap', 'last_edit_time'])
+ if not referenced_post.referenced_posts.filter(id=instance.id).exists():
+ referenced_post.referenced_posts.add(instance)
+ referenced_post.last_edit_time = instance.pub_time
+ referenced_post.build_refmap()
+ referenced_post.save(update_fields=['refmap', 'last_edit_time'])
except Post.ObjectDoesNotExist:
pass