Пример #1
0
 def update(self):
     toUpdate = self.request.get('id')
     post = Post.get_by_id(int(toUpdate))
     
     post.description = self.request.get('description')
     post.last_edit_author = str(users.get_current_user())
     
     if post.description and post.last_edit_author and toUpdate:
         post.put()
         self.redirect("/?msg=El post ha sido editado correctamente.")
     else:
         self.redirect('/?msg=El post no ha podido actualizarse.')
Пример #2
0
 def post(self, post_id):
     post = Post.get_by_id(int(post_id))
     content = self.request.get('content')
     # let's check if user is logged in
     if self.user:
         # and there is something in the content field
         if content:
             comment = Comment(post=post,
                               user=User.by_id(self.uid()),
                               content=content)
             comment.put()
             self.render_post(post)
         else:
             error = "Your comment can't be empty"
             self.render_post(post, error)
     # user not logged in, let's go to the login page
     else:
         self.redirect('/login')
Пример #3
0
 def post(self, post_id):
     post = Post.get_by_id(int(post_id))
     content = self.request.get('content')
     # let's check if user is logged in
     if self.user:
         # and there is something in the content field
         if content:
             comment = Comment(
                 post=post,
                 user=User.by_id(self.uid()),
                 content=content
                 )
             comment.put()
             self.render_post(post)
         else:
             error = "Your comment can't be empty"
             self.render_post(post, error)
     # user not logged in, let's go to the login page
     else:
         self.redirect('/login')
Пример #4
0
 def post(self, post_id):
     post = Post.get_by_id(int(post_id))
     # check if the user is the post owner
     if post.user.key().id() == self.uid():
         post.delete()
     self.redirect('/')
Пример #5
0
 def get(self, post_id):
     post = Post.get_by_id(int(post_id))
     self.render('delete-post.html', post=post, user=self.user)
Пример #6
0
 def get(self, post_id):
     post = Post.get_by_id(int(post_id))
     self.render_post(post)
Пример #7
0
 def post(self, post_id):
     post = Post.get_by_id(int(post_id))
     # check if the user is the post owner
     if post.user.key().id() == self.uid():
         post.delete()
     self.redirect('/')
Пример #8
0
 def get(self, post_id):
     post = Post.get_by_id(int(post_id))
     self.render('delete-post.html', post=post, user=self.user)
Пример #9
0
 def get(self, post_id):
     post = Post.get_by_id(int(post_id))
     self.render_post(post)