Skip to content

Commit

Permalink
Added a paragraphs attribute to the Entry model. Allows for easy acce…
Browse files Browse the repository at this point in the history
…ss to the first several paragraphs
  • Loading branch information
Corey Oordt committed May 6, 2011
1 parent 746d91e commit ad4a916
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#django-tagging
#django-categories
#django-tinymce
django-xmlrpc
django-xmlrpc
BeautifulSoup
8 changes: 7 additions & 1 deletion viewpoint/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ def get_absolute_url(self):
'slug': self.slug
}
return ('viewpoint_entry_detail', None, kwargs)
#

@property
def paragraphs():
text = "<html><head></head><body>" + self.body + "</body></html>"
soup = BeautifulSoup(text)
return [i for i in soup.body.childGenerator() if isinstance(i, Tag)]

if ENTRY_RELATION_MODELS:
def get_related_content_type(self, content_type):
return self.entryrelation_set.filter(content_type__name=content_type)
Expand Down

0 comments on commit ad4a916

Please sign in to comment.