コード例 #1
0
ファイル: tags.py プロジェクト: Git-Host/gaeframework
def get_recent_blogs(self, context):
    '''Get list of latest blog posts'''
    collection = Blog.all().filter("active", True).order("-created").fetch(10)
    if hasattr(self, "varname"):
        context[self.varname] = collection
        return ""
    return render_to_string("blogs/block/blogs_list",
                            {"blogs": collection},
                            context_instance = context)
コード例 #2
0
ファイル: controllers.py プロジェクト: Git-Host/gaeframework
def blogs_list(request):
    blogs = Blog.all().order('-created')
    # show not published blogs
    if request.GET.get("show") == "unpublished" and request.user:
        # show all blogs
        blogs.filter('active', False)
        # show only user blogs
        if not request.user.is_admin:
            blogs.filter('author', request.user)
    # show only active blogs
    else:
        blogs.filter('active', True)
    # render page
    return request.render(
        'blog/blogs_list',
        blogs = Pagination(request, blogs, 20, "blogs_page"),
    )