예제 #1
0
파일: views.py 프로젝트: lvbeck/net-fish
def list_all_post(request):
    posts = Post.all().order('-create_time')
    return object_list(request,
                       queryset=posts,
                       allow_empty=True,
                       template_name='list_post.html',
                       extra_context={'is_admin': is_admin()},
                       paginate_by=settings.POST_LIST_PAGE_SIZE)
예제 #2
0
파일: views.py 프로젝트: ytrstu/niubi
def list_all_post(request):
    posts = Post.all().order("-create_time")
    return object_list(
        request,
        queryset=posts,
        allow_empty=True,
        template_name="list_post.html",
        extra_context={"is_admin": is_admin()},
        paginate_by=settings.POST_LIST_PAGE_SIZE,
    )
예제 #3
0
파일: views.py 프로젝트: lvbeck/net-fish
def list_post(request):
    posts = Post.all().order('-create_time')
    if (not is_admin()):
        posts = posts.filter("is_published", True)
    return object_list(request,
                       queryset=posts,
                       allow_empty=True,
                       template_name='list_post.html',
                       extra_context={'is_author': is_author()},
                       paginate_by=settings.POST_LIST_PAGE_SIZE)
예제 #4
0
파일: views.py 프로젝트: ytrstu/niubi
def archives(request, year, month):
    # if month is not int:
    # raise Http404
    # return HttpResponse(month, content_type='text/plain')
    posts = Post.getByYM(year, month)
    return object_list(
        request,
        queryset=posts,
        allow_empty=True,
        template_name="list_archives_post.html",
        extra_context={"is_author": is_author(), "year": year, "month": month},
        paginate_by=settings.POST_LIST_PAGE_SIZE,
    )
예제 #5
0
파일: views.py 프로젝트: lvbeck/net-fish
def search(request):
    if request.REQUEST.has_key('q'):
        keywords = request.GET['q']
        logging.getLogger().info(keywords)
        posts = Post.all().search(keywords).order('-create_time')
        return object_list(request,
                           queryset=posts,
                           allow_empty=True,
                           template_name='search_post.html',
                           extra_context={'keywords': keywords},
                           paginate_by=settings.POST_LIST_PAGE_SIZE)
    else:
        return HttpResponseRedirect('/')
예제 #6
0
파일: views.py 프로젝트: ytrstu/niubi
def list_post(request):
    posts = None
    if not is_admin():
        posts = Post.all().filter("is_published", True).order("-create_time")
    else:
        posts = Post.all().order("-create_time")
    return object_list(
        request,
        queryset=posts,
        allow_empty=True,
        template_name="list_post.html",
        extra_context={"is_author": is_author()},
        paginate_by=settings.POST_LIST_PAGE_SIZE,
    )
예제 #7
0
파일: views.py 프로젝트: ytrstu/niubi
def list_tag_post(request, tag_name):
    tag = Tag.get_by_key_name(tag_name)
    if not tag:
        raise Http404
    # tag.getPosts().order('-create_time')
    tag.post_list = tag.getPosts()
    return object_list(
        request,
        queryset=tag.post_list,
        allow_empty=True,
        template_name="list_tag_post.html",
        extra_context={"is_author": is_author(), "is_author": is_author(), "tag": tag},
        paginate_by=settings.POST_LIST_PAGE_SIZE,
    )
예제 #8
0
파일: views.py 프로젝트: ytrstu/niubi
def list_category_post(request, category_id):
    category = Category.get_by_id(int(category_id))
    if not category:
        raise Http404
    posts = Post.all().filter("category", category).order("-create_time")

    return object_list(
        request,
        queryset=posts,
        allow_empty=True,
        template_name="list_category_post.html",
        extra_context={"is_author": is_author(), "category": category},
        paginate_by=settings.POST_LIST_PAGE_SIZE,
    )
예제 #9
0
파일: views.py 프로젝트: ytrstu/niubi
def search(request):
    if request.REQUEST.has_key("q"):
        keywords = request.GET["q"]
        logging.getLogger().info(keywords)
        posts = Post.all().search(keywords).order("-create_time")
        return object_list(
            request,
            queryset=posts,
            allow_empty=True,
            template_name="search_post.html",
            extra_context={"keywords": keywords},
            paginate_by=settings.POST_LIST_PAGE_SIZE,
        )
    else:
        return HttpResponseRedirect("/")
예제 #10
0
파일: views.py 프로젝트: lvbeck/net-fish
def archives(request, year, month):
    #if month is not int:
    #raise Http404
    #return HttpResponse(month, content_type='text/plain')
    posts = Post.getByYM(year, month)
    return object_list(request,
                       queryset=posts,
                       allow_empty=True,
                       template_name='list_archives_post.html',
                       extra_context={
                           'is_author': is_author(),
                           'year': year,
                           'month': month
                       },
                       paginate_by=settings.POST_LIST_PAGE_SIZE)
예제 #11
0
파일: views.py 프로젝트: lvbeck/net-fish
def list_category_post(request, category_id):
    category = Category.get_by_id(int(category_id))
    if not category:
        raise Http404
    posts = Post.all().filter('category', category).order('-create_time')

    return object_list(request,
                       queryset=posts,
                       allow_empty=True,
                       template_name='list_category_post.html',
                       extra_context={
                           'is_author': is_author(),
                           'category': category
                       },
                       paginate_by=settings.POST_LIST_PAGE_SIZE)
예제 #12
0
파일: views.py 프로젝트: lvbeck/net-fish
def list_tag_post(request, tag_name):
    tag = Tag.get_by_key_name(tag_name)
    if not tag:
        raise Http404
    # tag.getPosts().order('-create_time')
    tag.post_list = tag.getPosts()
    return object_list(request,
                       queryset=tag.post_list,
                       allow_empty=True,
                       template_name='list_tag_post.html',
                       extra_context={
                           'is_author': is_author(),
                           'is_author': is_author(),
                           'tag': tag
                       },
                       paginate_by=settings.POST_LIST_PAGE_SIZE)