Permalink
Browse files

Add flat_comments helper method to Document class

  • Loading branch information...
rosarior committed Apr 11, 2012
1 parent 0050fe4 commit ea49395c23eb659e04618cb80c112ff1773844a8
Showing with 7 additions and 0 deletions.
  1. +7 −0 apps/document_comments/__init__.py
@@ -40,6 +40,11 @@
register_links(Comment, [comment_delete])
register_links(Document, [comments_for_document], menu_name='form_header')
+
+def flat_comments(document):
+ return u' '.join(document.comments.values_list('comment', flat=True))
+
+
Document.add_to_class(
'comments',
generic.GenericRelation(
@@ -49,6 +54,8 @@
)
)
+Document.add_to_class('flat_comments', flat_comments)
+
class_permissions(Document, [
PERMISSION_COMMENT_CREATE,
PERMISSION_COMMENT_DELETE,

0 comments on commit ea49395

Please sign in to comment.