示例#1
0
 def get(self, comment_id):
     user = self.check_login()
     if user == "guest" or user == None:
         self.redirect("/blog/login")
     comment = Comment.get_by_id(int(comment_id))
     if not comment:
         return self.error(404)
     if user != comment.commenter:
         self.redirect("/blog")
     else:
         old_text = comment.text
         original_post = Message.get_by_id(int(comment.blog_id))
         self.render("editcomment.html",
                     user=user,
                     original_post=original_post,
                     old_text=old_text,
                     error="")
示例#2
0
 def post(self, blog_id):
     user = self.check_login()
     if user == "guest" or user == None:
         self.redirect("/blog/login")
     result = Message.get_by_id(int(blog_id))
     if not result:
         return self.error(404)
     comments = db.GqlQuery(
         "SELECT * FROM Comment WHERE blog_id='%s' ORDER BY created DESC" %
         blog_id)
     new_like = self.request.get("like")
     if new_like:
         result.like(new_like)
     self.render("result2.html",
                 user=user,
                 messages=result,
                 comments=comments)
示例#3
0
 def get(self, blog_id):
     user = self.check_login()
     if user == "guest" or user == None:
         self.redirect("/blog/login")
         return
     blogs = Message.get_by_id(int(blog_id))
     if not blogs:
         return self.error(404)
     if user != blogs.author:
         self.redirect("/blog")
     else:
         title = blogs.title
         text = blogs.text
         self.render("editblog.html",
                     user=user,
                     old_title=title,
                     old_text=text,
                     error="")
示例#4
0
 def get(self, blog_id):
     user = self.check_login()
     #if user=="guest" or user==None:
     #    self.redirect("/blog/login")
     #self.init_comment()
     comment = db.GqlQuery(
         "SELECT * FROM Comment WHERE blog_id='%s' ORDER BY created DESC" %
         blog_id)
     q_i = int(blog_id)
     comments = {}
     comments[q_i] = comment
     result = Message.get_by_id(int(blog_id))
     if not result:
         return self.error(404)
     self.render("result2.html",
                 user=user,
                 messages=result,
                 comments=comments)
示例#5
0
 def post(self, comment_id):
     #edit comment
     user = self.check_login()
     if user == "guest" or user == None:
         self.redirect("/blog/login")
     comment = Comment.get_by_id(int(comment_id))
     if not comment:
         return self.error(404)
     if user != comment.commenter:
         self.redirect("/blog")
     text = self.request.get("text")
     blog_id = comment.blog_id
     original_post = Message.get_by_id(int(comment.blog_id))
     if text == "":
         error = "Please input some word to modify!"
         self.render("editcomment.html",
                     original_post=original_post,
                     user=user,
                     old_text=text,
                     error=error)
     else:
         comment.modify(text=text)
         self.redirect("/blog/" + blog_id)
示例#6
0
 def post(self, blog_id):
     #edit blog
     user = self.check_login()
     if user == "guest" or user == None:
         self.redirect("/blog/login")
         return
     entity = Message.get_by_id(int(blog_id))
     if not entity:
         return self.error(404)
     if user != entity.author:
         self.redirect("/blog")
     title = self.request.get("title")
     text = self.request.get("text")
     if title == "" or text == "":
         error = "Please input some word to modify!"
         self.render("editblog.html",
                     user=user,
                     old_title=title,
                     old_text=text,
                     error=error)
     else:
         entity.modify(title=title, text=text)
         self.redirect("/blog/" + blog_id)