Ejemplo n.º 1
0
class CommentHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.dataController = DataController(self.application.con)

    def post(self):
        comment = dict()
        comment["userId"] = getUserIdFromCookie(self)
        if not comment["userId"]:
            self.redirect("/login", permanent=True)
            return
        comment["content"] = self.get_argument("content", "")
        comment["planId"] = self.get_argument("planId", "")
        commentId = self.dataController.createComment(comment)
        plan = self.dataController.getPlanById(comment["planId"])
        if comment["userId"] != plan["userId"]:
            message = dict()
            message["planId"] = comment["planId"]
            message["sid"] = comment["userId"]
            message["rid"] = plan["userId"]
            message["cid"] = commentId
            message["state"] = 3
            self.dataController.createMessage(message)
        self.redirect("/plan?planId=" + str(comment["planId"]), permanent=True)
Ejemplo n.º 2
0
class CommentHandler(tornado.web.RequestHandler):
	def initialize(self):
		self.dataController = DataController(self.application.con)

	def post(self):
		comment = dict()
		comment['userId'] = getUserIdFromCookie(self)
		if not comment['userId']:
			self.redirect('/login', permanent=True)
			return
		comment['content'] = self.get_argument('content', '')
		comment['planId'] = self.get_argument('planId', '')
		commentId = self.dataController.createComment(comment)
		plan = self.dataController.getPlanById(comment['planId'])
		if comment['userId'] != plan['userId']:
			message = dict()
			message['planId'] = comment['planId']
			message['sid'] = comment['userId']
			message['rid'] = plan['userId']
			message['cid'] = commentId
			message['state'] = 3
			self.dataController.createMessage(message)
		self.redirect('/plan?planId='+str(comment['planId']), permanent=True)