Example #1
0
def list_category(request, category_id):
    category = Category.get_by_id( int(category_id) )

    posts = category.posts.order('-create_time')

    return object_list(request,
                       template_object_name = 'post',
                       queryset = posts,
                       extra_context = { 'cort':category, 'type':'Category' },
                       allow_empty = True,
                       template_name = 'page.html',
                       paginate_by = LIST_PER_PAGE,
                       )
Example #2
0
def index(request):
    posts = Post.all().order('-create_time')
    
    #return test_list(request, queryset=posts, paginate_by=LIST_PER_PAGE, template_name='index.html', 
    #    extra_context={}, template_object_name='post') 
    return object_list(request,
                       template_object_name = 'post',
                       queryset = posts,
                       allow_empty = True,
                       extra_context = {},
                       template_name = 'index.html',
                       paginate_by = LIST_PER_PAGE,
                       )
Example #3
0
def admin_list_category(request):
    if users.is_current_user_admin():
        
        return object_list(request,
                       template_object_name='obj',
                       queryset=Category.all(),
                       allow_empty=True,
                       extra_context={'type': 'category'},
                       template_name='admin/list.html',
                       paginate_by=setting.ADMIN_LIST_PER_PAGE,
                       )
    else:
        return HttpResponseRedirect('/')
Example #4
0
def admin_list_category(request):
    if users.is_current_user_admin():

        return object_list(
            request,
            template_object_name='obj',
            queryset=Category.all(),
            allow_empty=True,
            extra_context={'type': 'category'},
            template_name='admin/list.html',
            paginate_by=setting.ADMIN_LIST_PER_PAGE,
        )
    else:
        return HttpResponseRedirect('/')
Example #5
0
def list_tag(request, tag_id):
    tag = Tag.get_by_id( int(tag_id) )

    posts = []
    for post in tag.posts:
        posts.append(post.post)

    return object_list(request,
                       template_object_name = 'post',
                       queryset = posts,
                       extra_context = { 'cort':tag, 'type':'Tag' },
                       allow_empty = True,
                       template_name = 'page.html',
                       paginate_by = LIST_PER_PAGE,
                       )