]> git.openstreetmap.org Git - osqa.git/commitdiff
SPLUNK-196, making filtration to the summary and headline properties of the Node...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 6 Apr 2011 16:51:31 +0000 (16:51 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 6 Apr 2011 16:51:31 +0000 (16:51 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@937 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/node.py

index 0ebcd21ccfc2b203888135ee53e5692f6ecd75d2..a71ae4725898fbfc7dc6cddaa854590b9f248d39 100644 (file)
@@ -43,7 +43,12 @@ class NodeContent(models.Model):
 
     @property
     def headline(self):
-        return self.title
+        title = self.title
+
+        # Replaces multiple spaces with single ones.
+        title = re.sub(' +',' ', title)
+
+        return title
 
     def tagname_list(self):
         if self.tagnames:
@@ -309,7 +314,15 @@ class Node(BaseModel, NodeContent):
 
     @property
     def summary(self):
-        return strip_tags(self.html)[:SUMMARY_LENGTH]
+        content = strip_tags(self.html)[:SUMMARY_LENGTH]
+
+        # Remove multiple spaces.
+        content = re.sub(' +',' ', content)
+
+        # Remove line breaks. We don't need them at all.
+        content = content.replace("\n", '')
+
+        return content
 
     @models.permalink
     def get_revisions_url(self):