Ejemplo n.º 1
0
def add_reply(pid):
    # name = self.get_argument("reply[name]", default='')
    # email = self.get_argument("reply[email]", default='')
    # website = self.get_argument("reply[website]", default='')
    # origin_content = self.get_argument("reply[content]", default='')
    name = request.form["reply[name]"]
    email = request.form["reply[email]"]
    website = request.form["reply[website]"]
    origin_content = request.form["reply[content]"]
    content = markdown.markdown(formatText(origin_content))
    if name == "":
        return redirect("/post/%d" % int(pid), error=u"请填入名字")
    if email == "":
        return redirect("/post/%d" % int(pid), error=u"请填入邮箱地址")
    if origin_content == "":
        return redirect("/post/%d" % int(pid), error=u"请输入评论内容")
    number = db.query(Reply).filter(Reply.pid == pid).count() + 1
    db.add(
        Reply(
            pid=int(pid),
            name=name,
            email=email,
            website=website,
            content=content,
            origin_content=origin_content,
            number=number,
        )
    )
    db.commit()
    base.replyerSet(name, email, website)
    return redirect("/post/%d" % (int(pid)))
Ejemplo n.º 2
0
def add_reply(pid):
    #name = self.get_argument("reply[name]", default='')
    #email = self.get_argument("reply[email]", default='')
    #website = self.get_argument("reply[website]", default='')
    #origin_content = self.get_argument("reply[content]", default='')
    name = request.form["reply[name]"]
    email = request.form["reply[email]"]
    website = request.form["reply[website]"]
    origin_content = request.form["reply[content]"]
    content = markdown.markdown(formatText(origin_content))
    if name == "":
        return redirect("/post/%d" % int(pid), error=u"请填入名字")
    if email == "":
        return redirect("/post/%d" % int(pid), error=u"请填入邮箱地址")
    if origin_content == "":
        return redirect("/post/%d" % int(pid), error=u"请输入评论内容")
    number = db.query(Reply).filter(Reply.pid == pid).count() + 1
    db.add(
        Reply(pid=int(pid),
              name=name,
              email=email,
              website=website,
              content=content,
              origin_content=origin_content,
              number=number))
    db.commit()
    base.replyerSet(name, email, website)
    return redirect("/post/%d" % (int(pid)))
Ejemplo n.º 3
0
 def post(self, pid):
     name = self.get_argument("reply[name]", default='')
     email = self.get_argument("reply[email]", default='')
     website = self.get_argument("reply[website]", default='')
     origin_content = self.get_argument("reply[content]", default='')
     content = formatText(md(formatText(origin_content)))
     if name == "":
         self.redirect("/post/%d" % int(pid), error=u"请填入名字")
     if email == "":
         self.redirect("/post/%d" % int(pid), error=u"请填入邮箱地址")
     if origin_content == "":
         self.redirect("/post/%d" % int(pid), error=u"请输入评论内容")
     number = db.query(Reply).filter(Reply.pid == pid).count() + 1
     db.add(Reply(pid=int(pid), name=name, email=email, website=website,
         content=content, origin_content=origin_content, number=number))
     db.commit()
     self.replyerSet(name, email, website)
     self.redirect("/post/%d#%d" % (int(pid), int(number)))
Ejemplo n.º 4
0
 def post(self, pid, id):
     self.checkAdmin()
     name = self.get_argument("reply[name]", default='')
     email = self.get_argument("reply[email]", default='')
     website = self.get_argument("reply[website]", default='')
     origin_content = self.get_argument("reply[content]", default='')
     content = md(formatText(origin_content))
     if name == "":
         self.redirect("/post/%d" % int(pid), error=u"请填入名字")
     if email == "":
         self.redirect("/post/%d" % int(pid), error=u"请填入邮箱地址")
     if origin_content == "":
         self.redirect("/post/%d" % int(pid), error=u"请输入评论内容")
     reply = db.query(Reply).get(id)
     if reply is None:
         raise tornado.web.HTTPError(404)
     reply.name = name
     reply.email = email
     reply.website = website
     reply.origin_content = origin_content
     reply.content = content
     db.commit()
     self.replyerSet(name, email, website)
     self.redirect("/post/%d#%d" % (int(pid), int(reply.number)))