From: jordan Date: Wed, 6 Apr 2011 16:51:31 +0000 (+0000) Subject: SPLUNK-196, making filtration to the summary and headline properties of the Node... X-Git-Tag: live~373 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/c502a60cd16d8ae64710c9b1c22b2fadf7ed3e51?ds=sidebyside SPLUNK-196, making filtration to the summary and headline properties of the Node model, removing multiple spaces and new lines breaks, we don't need them and they cause trouble to the title attribute of the tag. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@937 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/models/node.py b/forum/models/node.py index 0ebcd21..a71ae47 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -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):