Added "entry_dates" method to model to provide distinct yearly, monthly and daily...
authorKriti Godey <kriti.godey@gmail.com>
Fri, 23 Jul 2010 14:06:51 +0000 (19:36 +0530)
committerKriti Godey <kriti.godey@gmail.com>
Fri, 23 Jul 2010 14:29:04 +0000 (19:59 +0530)
contrib/penfield/models.py

index eede5a4..0a46c54 100644 (file)
@@ -15,6 +15,11 @@ class Blog(Entity, Titled):
        def entry_tags(self):
                """ Returns a QuerySet of Tags that are used on any entries in this blog. """
                return Tag.objects.filter(blogentries__blog=self).distinct()
+       
+       @property
+       def entry_dates(self):
+               dates = {'year': self.entries.dates('date', 'year', order='DESC'), 'month': self.entries.dates('date', 'month', order='DESC'), 'day': self.entries.dates('date', 'day', order='DESC')}
+               return dates
 
 
 register_value_model(Blog)