예제 #1
0
    def get(self, page=1):
        query = models.Post.all().order('-published_date')
        pager = PagedQuery(query, 30)
        posts = pager.fetch_page(int(page))

        self.context_vars = {
                'posts': posts,
            }
        return self.render('admin_posts.html')
예제 #2
0
    def get(self, page=1):
        query = models.Post.all().filter('published = ', False).order('-created_date')
        pager = PagedQuery(query, 30)
        posts = pager.fetch_page(int(page))

        self.context_vars = {
                'posts': posts,
                'title': 'Drafts',
            }
        return self.render('admin_posts.html')
예제 #3
0
    def get(self, year=None, month=None, page=1):
        ''' display one page of archived posts '''
        page = int(page)
        post_query = models.Post.all().filter('published = ', True).filter(
                    'published_date < ', datetime.datetime.now()
                ).order('-published_date')
        q = PagedQuery(post_query, 10)
        posts = q.fetch_page(page)

        self.context_vars = {
                'page_title': 'Blog archive',
                'page': page,
                'posts': posts,
                'path': '/',
                'has_prev': q.has_page(page - 1),
                'has_next': q.has_page(page + 1),
            }

        self.render('blog_archive.html')
예제 #4
0
    def get(self, slug, page=1):
        ''' view one page of archved posts in a category '''
        page = int(page)
        cats = models.Category.get_dict()
        post_query = models.Post.all().filter('published = ', True).filter(
                    'categories = ', slug).filter(
                    'published_date < ', datetime.datetime.now()
                ).order('-published_date')
        q = PagedQuery(post_query, 10)
        posts = q.fetch_page(page)

        self.context_vars = {
                'page_title': cats[slug],
                'page': page,
                'posts': posts,
                'path': '/topic/%s/' % slug,
                'has_prev': q.has_page(page - 1),
                'has_next': q.has_page(page + 1),
            }

        self.render('blog_archive.html')
예제 #5
0
    def get(self, slug, page=1):
        ''' view one page of archived posts with a specified tag '''
        page = int(page)
        tags = models.Tag.get_dict()
        post_query = models.Post.all().filter(
                    'published = ', True
                ).filter(
                    'tags = ', slug
                ).filter(
                    'published_date < ', datetime.datetime.now()
                ).order('-published_date')
        q = PagedQuery(post_query, 10)
        posts = q.fetch_page(page)

        self.context_vars = {
                'page_title': 'Posts about: <em>%s</em>' % tags[slug],
                'page': page,
                'posts': posts,
                'path': '/tag/%s/' % slug,
                'has_prev': q.has_page(page - 1),
                'has_next': q.has_page(page + 1),
            }

        self.render('blog_archive.html')