示例#1
0
    def get(self):
        """
        If the user is logged in then render the existing blog posts
        """
        current_user = self.authenticate_user()
        posts = Post.query().fetch()

        if current_user:
            self.render("main.html", posts=posts, current_user=current_user)
        else:
            self.render("main.html", posts=posts)
示例#2
0
    def get(self):
        template_values = {'posts': []}

        posts = Post.query().order(-Post.created)

        for post in posts:
            template_values['posts'].append({
                'title':
                post.title,
                'content':
                post.content,
                'created':
                post.created.strftime('%B %d, %Y'),
                'id':
                post.key.id(),
            })

        print template_values

        self.render('index', template_values)
示例#3
0
 def get(self):
     q = Post.query().order(-Post.created)
     posts = q.fetch(limit=10)
     if posts:
         self.render("main.html", posts=posts)