Guilherme Gondim committed 49b4ce2

Add lead property

  • Participants
  • Parent commits ebe6d19

Comments (0)

Files changed (2)

File diario/

         Default value for ``Entry.allow_comments`` boolean field.
         Default: True
+        The number of words the property ``Entry.lead`` should use to
+        trucante body. Default: 25
         Number of itens per page on list and archive views. Default: 12
 ALLOW_COMMENTS = getattr(settings, 'DIARIO_ALLOW_COMMENTS', True)
+LEAD_SIZE = getattr(settings, 'DIARIO_LEAD_SIZE', True)
 PAGINATE_BY = getattr(settings, 'DIARIO_PAGINATE_BY', 12)
     # ('archived', _('Archived')),

File diario/

 from django.contrib.auth.models import User
 from django.db import models
+from django.utils.text import Truncator
 from django.utils.translation import ugettext_lazy as _
 from django.utils.timezone import now
 from taggit.managers import TaggableManager
     def is_hidden(self):
         return not self.status in self.VISIBLE_STATUS
+    @property
+    def lead(self):
+        return Truncator(self.body).words(
+            app_settings.LEAD_SIZE,
+            truncate=' ...'
+        )