示例#1
0
def blogindex(request, group, category_id = None):
    categories = get_board_categories(group)
    if category_id is not None:
        category_id = int(category_id)
        categories = [category for category in categories \
                          if category.id == category_id]
    if not categories:
        return render_to_response( 'sphene/sphblog/nocategory.html',
                                   { },
                                   context_instance = RequestContext(request) )

    threads = get_posts_queryset(group, categories)

    allowpostcategories = filter(Category.has_post_thread_permission, categories)
    #blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), args = ('latestposts',), kwargs = { 'groupName': group.name })
    blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), kwargs = { 'url': 'latestposts' })
    add_rss_feed( blog_feed_url, 'Blog RSS Feed' )
    all_tags = get_tags_for_categories( categories )
    return render_to_response( 'sphene/sphblog/blogindex.html',
                               { 'allowpostcategories': allowpostcategories,
                                 'threads': threads,
                                 'blog_feed_url': blog_feed_url,
                                 'all_tags': all_tags,
                                 },
                               context_instance = RequestContext(request) )
示例#2
0
def blogindex(request,
              group,
              category_id=None,
              category_slug=None,
              page=1,
              year=None,
              month=None):
    """
    shows a blog posts list. year and month parameters
    are used for archive functionality.
    """

    category_info = get_category_info(category_id=category_id,
                                      category_slug=category_slug,
                                      group=group)
    if not category_info:
        return render_to_response('sphene/sphblog/nocategory.html', {},
                                  context_instance=RequestContext(request))
    context_variables = {}
    if year:
        context_variables['archive_year'] = year
        year = int(year)

        if month:
            context_variables['archive_month'] = month
            month = int(month)

    threads = get_posts_queryset(group, category_info[0], year, month)

    paged_threads = get_paged_objects(threads, page)

    allowpostcategories = filter(Category.has_post_thread_permission,
                                 category_info[0])
    #blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), args = ('latestposts',), kwargs = { 'groupName': group.name })
    blog_feed_url = sph_reverse('sphblog-feeds')
    #, kwargs = { 'url': 'latestposts' })
    add_rss_feed(blog_feed_url, 'Blog RSS Feed')
    all_tags = get_tags_for_categories(category_info[0])

    context_variables.update({
        'allowpostcategories': allowpostcategories,
        'threads': paged_threads,
        'blog_feed_url': blog_feed_url,
        'all_tags': all_tags,
        'category': category_info[1],
        'categories': category_info[0],
        'group': group,
    })

    return render_to_response('sphene/sphblog/blogindex.html',
                              context_variables,
                              context_instance=RequestContext(request))
示例#3
0
def blogindex(request, group, category_id = None, category_slug = None, page = 1, year=None, month=None):
    """
    shows a blog posts list. year and month parameters
    are used for archive functionality.
    """

    category_info = get_category_info(category_id = category_id,
                                      category_slug = category_slug,
                                      group = group)
    if not category_info:
        return render_to_response('sphene/sphblog/nocategory.html',
                                  {},
                                  context_instance = RequestContext(request))
    context_variables = {}
    if year:
        context_variables['archive_year'] = year
        year = int(year)

        if month:
            context_variables['archive_month'] = month
            month = int(month)

    threads = get_posts_queryset(group, category_info[0], year, month)

    paged_threads = get_paged_objects(threads, page)

    allowpostcategories = filter(Category.has_post_thread_permission, category_info[0])
    #blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), args = ('latestposts',), kwargs = { 'groupName': group.name })
    blog_feed_url = sph_reverse('sphblog-feeds');#, kwargs = { 'url': 'latestposts' })
    add_rss_feed( blog_feed_url, 'Blog RSS Feed' )
    all_tags = get_tags_for_categories( category_info[0] )

    context_variables.update({'allowpostcategories': allowpostcategories,
                              'threads': paged_threads,
                              'blog_feed_url': blog_feed_url,
                              'all_tags': all_tags,
                              'category': category_info[1],
                              'categories': category_info[0],
                              'group': group,
                              })

    return render_to_response( 'sphene/sphblog/blogindex.html',
                               context_variables,
                               context_instance = RequestContext(request) )