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)
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)
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)
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)
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('/')
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)