Commits

cur...@tinbrain.net  committed 77be692

Changed to gnocchi_blog namespace
Updated for Django-1.3 Class-based generic views
Bumped version

  • Participants
  • Parent commits c3a1a61

Comments (0)

Files changed (5)

File blog/admin.py

 from django.contrib import admin
-from django.views.generic.simple import direct_to_template
-from django.conf.urls.defaults import patterns, url
-from django.http import HttpResponseRedirect
-
-from gnocchi2.blog import models
+from gnocchi_blog import models
 
 register = admin.site.register
 
         obj.save()
 
 register( models.BlogPost, BlogPostAdmin )
-

File blog/feeds.py

 from django.contrib.syndication.views import Feed
-from gnocchi2.blog.models import BlogPost
+from gnocchi_blog.models import BlogPost
 from taggit.models import TaggedItem
 
 class LatestBlogFeed(Feed):
 
     def item_categories(self, item):
         return item.tags
-
-

File blog/search_indexes.py

 
 from haystack.indexes import SearchIndex, CharField
 from haystack import site
-from gnocchi2.blog.models import BlogPost
+from gnocchi_blog.models import BlogPost
 
 class BlogPostIndex(SearchIndex):
     text = CharField(document=True, use_template=True)
     title = CharField(model_attr='title')
 
 site.register(BlogPost, BlogPostIndex)
-

File blog/views.py

-from django.views.generic import date_based, list_detail
+from gnocchi_blog.models import BlogPost
 
-from gnocchi2.blog.models import BlogPost
+class BlogPostMixin(object):
+    date_field = 'post_date'
+    slug_field = 'slug'
+    username = None
 
-def _build_queryset(request, username=None, **kw):
-    qset = BlogPost.objects.current()
-    if username:
-        qset = qset.filter( user__username=username )
-    tags = request.GET.getlist('tags')
-    if tags:
-        return qset.filter(tags__in=tags)
-    return qset
-
-def blog_index(request, *a, **kw):
-    return date_based.archive_index(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        *a, **kw)
-
-def blog_year(request, *a, **kw):
-    return date_based.archive_year(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date', *a, **kw)
-
-def blog_month(request, *a, **kw):
-    return date_based.archive_month(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        *a, **kw)
-
-def blog_week(request, *a, **kw):
-    return date_based.archive_week(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        *a, **kw)
-
-def blog_day(request, *a, **kw):
-    return date_based.archive_day(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        *a, **kw)
-
-def blog_today(request, *a, **kw):
-    return date_based.archive_today(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        *a, **kw)
-
-def blog_detail(request, *a, **kw):
-    return date_based.object_detail(request,
-        queryset=_build_queryset(request, *a, **kw),
-        date_field='post_date',
-        slug_field='slug',
-        *a, **kw)
-
-def blog_list(request, *a, **kw):
-    return list_detail.object_list(request,
-        queryset=_build_queryset(request, *a, **kw),
-        *a, **kw)
-
+    def get_queryset(self):
+        qset = BlogPost.objects.current()
+        if self.username:
+            qset = qset.filter(user__username=self.username)
+        tags = self.request.GET.getlist('tags')
+        if tags:
+            qset = qset.filter(tags__in=tags)
+        return qset
 from distutils.core import setup
 
 setup( name='gnocchi-blog',
-    version = '1.0',
+    version = '1.1',
     description = 'A simple multi-user Blog',
     author = 'Curtis Maloney',
     author_email = 'curtis@tinbrain.net',
     url = 'http://bitbucket.org/funkybob/gnocchi-blog/',
     keywords = [ 'django', 'blog', ],
     packages = [
-        'gnocchi2.blog',
-        'gnocchi2.blog.templatetags',
+        'gnocchi_blog',
+        'gnocchi_blog.templatetags',
     ],
     package_dir = {
-        'gnocchi2.blog': 'blog',
+        'gnocchi_blog': 'blog',
     },
     package_data = {
-        'gnocchi2.blog': [
+        'gnocchi_blog': [
             'templates/search/indexes/blog/blogpost_text.txt',
         ]
     },
         'Programming Language :: Python',
     ],
     requires = [
-        'Django (>1.2)',
+        'Django (>1.3)',
         'taggit (>=0.8.0)',
     ]
 )