def archive_list(request): """Returns a list of months by year with published posts.""" dates = Post.objects.published().order_by('pub_date').dates('pub_date', 'month') return render_with_context(request, 'blog/archive_list.xhtml', { 'dates': dates, 'title': 'Post Archive', })
def tag_list(request, slug): """Returns blog entries for this tag slug.""" tag = get_object_or_404(Tag, slug=slug) posts = Post.objects.published().filter(tags__tag__slug=slug) return render_with_context(request, 'blog/post_list.xhtml', { 'posts': posts, 'title': 'Posts tagged under %s' % tag.text, })
def post_year(request, year): """Returns all posts for a particular year.""" tt = time.strptime('-'.join([year]), '%Y') date = datetime.date(*tt[:3]) posts = Post.objects.published().filter(pub_date__year=date.year) return render_with_context(request, 'blog/post_list.xhtml', { 'posts': posts, 'title': 'Posts for %s' % date.strftime("%Y"), })
def topics(request): """Returns a list of all top level topics for display and linking.""" topics = Topic.objects.filter(parent__isnull=True) # all top level topics. return render_with_context( request, "ontology/topic_list.xhtml", {"title": "All Topics", "description": "The following is a list of tags used for content.", "topics": topics}, )
def tags(request): """Returns a list of all tags for display and linking.""" tags = Tag.objects.all() return render_with_context( request, "ontology/tag_list.xhtml", {"title": "All Tags", "description": "The following is a list of tags used for content.", "tags": tags}, )
def post_day(request, year, month, day): """Returns all posts for a particular day.""" tt = time.strptime('-'.join([year, month, day]), '%Y-%b-%d') date = datetime.date(*tt[:3]) posts = Post.objects.published().filter(pub_date__year=date.year, pub_date__month=date.month, pub_date__day=date.day) return render_with_context(request, 'blog/post_list.xhtml', { 'posts': posts, 'title': 'Posts for %s' % date.strftime("%A, %d %B %Y"), })
def post_all(request): """Returns all User Blogs""" posts = Post.objects.published() alt_links = [ {'type': 'application/atom+xml', 'title': 'Atom Feed', 'href': '%s?format=rss' % reverse('blog:index')} ] return render_with_context(request, 'blog/post_list.xhtml', { 'title': 'All Posts', 'posts': posts, 'alt_links': alt_links, })
def post_detail(request, year, month, day, slug): """Returns an individual post.""" tt = time.strptime('-'.join([year, month, day]), '%Y-%b-%d') date = datetime.date(*tt[:3]) try: post = Post.objects.published().get(slug=slug, pub_date__year=date.year, pub_date__month=date.month, pub_date__day=date.day) except Post.DoesNotExist: raise Http404 return render_with_context(request, 'blog/post_detail.xhtml', { 'post': post, 'title': post.title, })
def tag(request, slug): """ Returns a list of content related to a specific tag. :param slug: Tag slug to return content for. """ tag = get_object_or_404(Tag, slug=slug) catalog = tag.taggeditem_set.all() # @TODO Change to published Only!! contentlist = [item for item in catalog if item.content_object.status == "P"] return render_with_context( request, "ontology/tag_items.xhtml", {"title": "Items Under %s" % tag.text, "tag": tag, "contentlist": contentlist}, )