def GET(self, id): try: id = int(id) except: raise web.notfound() comment = web.ctx.orm.query(Comment).filter(Comment.id == id).first() return admin_render.comment_edit(comment=comment)
def POST(self, id): i = web.input() referer = web.ctx.env.get("HTTP_REFERER", "/comments") comment = web.ctx.orm.query(Comment).filter(Comment.id == int(id)).first() # update the comment data and commit it if not (i.author and i.email and i.content): msg = "Author, email, content field can not be empty!" return admin_render.comment_edit(comment=comment, msg=msg) comment.author = i.author comment.email = i.email comment.url = i.url comment.content = i.content if i.comment_status == "approved": comment.status = i.comment_status elif i.comment_status == "spam": comment.status = i.comment_status else: comment.status = i.comment_status web.ctx.orm.commit() msg = "Comment has been updated successfully!" return admin_render.comment_edit(comment=comment, msg=msg)