Merge branch 'master' of git://github.com/melinath/philo
[philo.git] / contrib / penfield / models.py
index b970643..a03bed8 100644 (file)
@@ -46,6 +46,7 @@ class FeedView(MultiView):
        feed_type = models.CharField(max_length=50, choices=FEED_CHOICES, default=ATOM)
        feed_suffix = models.CharField(max_length=255, blank=False, default="feed")
        feeds_enabled = models.BooleanField(default=True)
+       feed_length = models.PositiveIntegerField(blank=True, null=True, default=15, help_text="The maximum number of items to return for this feed. All items will be returned if this field is blank.")
        
        item_title_template = models.ForeignKey(Template, blank=True, null=True, related_name="%(app_label)s_%(class)s_title_related")
        item_description_template = models.ForeignKey(Template, blank=True, null=True, related_name="%(app_label)s_%(class)s_description_related")
@@ -195,6 +196,9 @@ class FeedView(MultiView):
                except Site.DoesNotExist:
                        current_site = RequestSite(request)
                
+               if self.feed_length is not None:
+                       items = items[:self.feed_length]
+               
                for item in items:
                        if title_template is not None:
                                title = title_template.render(RequestContext(request, {'obj': item}))