diff --git a/models.py b/models.py
index 3cb6e1d..14fa5be 100644
--- a/models.py
+++ b/models.py
@@ -27,7 +27,8 @@ from re import sub
from datetime import datetime
from django.db import models
from django.contrib.auth.models import User
-from django.db.models.signals import post_init, pre_delete, post_delete, post_save
+from django.db.models.signals import pre_init, post_init, pre_delete, post_delete
+from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from dynastie.generators import *
@@ -362,6 +363,12 @@ class Comment(models.Model):
the_comment = models.TextField(max_length=255)
ip = models.GenericIPAddressField()
+ def _update_line_returns(self):
+ self.the_comment = self.the_comment.replace('\n', '
')
+
+ def _remove_br(self):
+ self.the_comment = self.the_comment.replace('
', '\n')
+
@receiver(post_init, sender=Blog)
def init_blog_signal(sender, **kwargs):
kwargs['instance'].create_paths()
@@ -386,3 +393,8 @@ def delete_post_signal(sender, **kwargs):
def pre_delete_post_signal(sender, **kwargs):
post = kwargs['instance']
comments = Comment.objects.filter(post=post.id).delete()
+
+# Replace line returns by
for generation
+@receiver(pre_save, sender=Comment)
+def pre_save_comment_signal(sender, **kwargs):
+ kwargs['instance']._update_line_returns()
diff --git a/templates/edit_post.html b/templates/edit_post.html
index 561c56c..983c814 100644
--- a/templates/edit_post.html
+++ b/templates/edit_post.html
@@ -18,10 +18,12 @@
{% for comment in comments %}