Added filter_horizontal on blogentry tags. Made minor corrections to BlogView's get_e...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Wed, 22 Sep 2010 14:51:11 +0000 (10:51 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 23 Sep 2010 16:31:56 +0000 (12:31 -0400)
contrib/penfield/admin.py
contrib/penfield/models.py

index 56edd45..85888aa 100644 (file)
@@ -13,7 +13,7 @@ class BlogAdmin(TitledAdmin):
 
 
 class BlogEntryAdmin(TitledAdmin):
-       pass
+       filter_horizontal = ['tags']
 
 
 class BlogViewAdmin(EntityAdmin):
index 940f7e7..7385dd9 100644 (file)
@@ -178,7 +178,7 @@ class BlogView(MultiView, FeedMultiViewMixin):
                context.update({'year': year, 'month': month, 'day': day})
                return entries, context
        
-       def get_entries_by_tag(self, request, node=None, extra_context=None):
+       def get_entries_by_tag(self, request, tag_slugs, node=None, extra_context=None):
                tags = []
                for tag_slug in tag_slugs.replace('+', '/').split('/'):
                        if tag_slug: # ignore blank slugs, handles for multiple consecutive separators (+ or /)
@@ -193,10 +193,12 @@ class BlogView(MultiView, FeedMultiViewMixin):
                entries = self.blog.entries.all()
                for tag in tags:
                        entries = entries.filter(tags=tag)
-               if entries.count() <= 0:
-                       raise Http404
                
-               return entries, extra_context
+               context = self.get_context()
+               context.update(extra_context or {})
+               context.update({'tags': tags})
+               
+               return entries, context
        
        def get_obj_description(self, obj):
                return obj.excerpt