Esempio n. 1
0
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		answer_id = db.add_answer(params)
		if answer_id == -1:
			resp[KEY.STATUS] = STATUS.ERROR
		else:
			resp[KEY.STATUS] = STATUS.OK
			event_info = db.get_event_information({KEY.EVENT_ID: params[KEY.EVENT_ID]})
			user_info = db.get_user_information({KEY.ID: event_info[KEY.LAUNCHER_ID]})
			user_info = utils.trans_unicode_to_utf(user_info)
			event_info = utils.trans_unicode_to_utf(event_info)
			
			is_like = 0
			if db.is_user_like_event({KEY.ID: event_info[KEY.LAUNCHER_ID], KEY.EVENT_ID: params[KEY.EVENT_ID]}):
				is_like = 1

			custom = {KEY.EVENT_ID: params[KEY.EVENT_ID], KEY.NICKNAME: user_info[KEY.NICKNAME], KEY.TIME: event_info[KEY.TIME], KEY.TITLE: event_info[KEY.TITLE], \
			KEY.CONTENT: event_info[KEY.CONTENT], KEY.LOVE_COIN: event_info[KEY.LOVE_COIN], KEY.FOLLOW_NUMBER: event_info[KEY.FOLLOW_NUMBER],\
			KEY.SUPPORT_NUMBER: event_info[KEY.SUPPORT_NUMBER], KEY.IS_LIKE: is_like}
			custom['message-type'] = 5
			mess = sendHelp.buildMessage(type=1, title=title, content=content, style=style, action=action, custom=custom)
			print sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
			'''and send the tongyou message'''
			mess = sendHelp.buildMessage(custom=custom)
			print sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)

		resp[KEY.ANSWER_ID] = answer_id
		self.write(json_encode(resp))
 def post(self):
   params = utils.decode_params(self.request)
   answer = db.add_answer(params)
   resp = {}
   if answer_flag > 0:
     resp[KEY.STATUS] = STATUS.OK
   
   return self.write(json_encode(resp))
  def post(self):
    params = utils.decode_params(self.request)

    resp = {}
    answer_id = db.add_answer(params)
    if answer_id > 0:
      answer_info = {}
      answer_info[KEY.ANSWER_ID] = answer_id
      resp = db.get_answer_info(answer_info)
      if resp is None:
        resp = {}
      resp[KEY.STATUS] = STATUS.OK
    else:
      resp[KEY.STATUS] = STATUS.ERROR

    self.write(json_encode(resp))
Esempio n. 4
0
    def post(self):
        params = utils.decode_params(self.request)

        resp = {}
        answer_id = db.add_answer(params)
        if answer_id > 0:
            answer_info = {}
            answer_info[KEY.ANSWER_ID] = answer_id
            resp = db.get_answer_info(answer_info)
            if resp is None:
                resp = {}
            resp[KEY.STATUS] = STATUS.OK
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))
Esempio n. 5
0
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        answer_id = db.add_answer(params)
        if answer_id == -1:
            resp[KEY.STATUS] = STATUS.ERROR
        else:
            resp[KEY.STATUS] = STATUS.OK
            event_info = db.get_event_information(
                {KEY.EVENT_ID: params[KEY.EVENT_ID]})
            user_info = db.get_user_information(
                {KEY.ID: event_info[KEY.LAUNCHER_ID]})
            helper_info = db.get_user_information({KEY.ID: params[KEY.ID]})
            user_info = utils.trans_unicode_to_utf(user_info)
            helper_info = utils.trans_unicode_to_utf(helper_info)
            event_info = utils.trans_unicode_to_utf(event_info)

            is_like = 0
            if db.is_user_like_event({
                    KEY.ID: event_info[KEY.LAUNCHER_ID],
                    KEY.EVENT_ID: params[KEY.EVENT_ID]
            }):
                is_like = 1

            custom = {KEY.EVENT_ID: params[KEY.EVENT_ID], KEY.NICKNAME: helper_info[KEY.NICKNAME], KEY.LAUNCHER: user_info[KEY.NICKNAME], KEY.TIME: event_info[KEY.TIME], KEY.TITLE: event_info[KEY.TITLE], \
            KEY.CONTENT: event_info[KEY.CONTENT], KEY.LOVE_COIN: event_info[KEY.LOVE_COIN], KEY.FOLLOW_NUMBER: event_info[KEY.FOLLOW_NUMBER],\
            KEY.SUPPORT_NUMBER: event_info[KEY.SUPPORT_NUMBER], KEY.IS_LIKE: is_like}
            custom['message-type'] = 5
            mess = sendHelp.buildMessage(type=1,
                                         title=title,
                                         content=content,
                                         style=style,
                                         action=action,
                                         custom=custom)
            sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
            '''and send the tongyou message'''
            mess = sendHelp.buildMessage(custom=custom)
            sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)

        resp[KEY.ANSWER_ID] = answer_id
        self.write(json_encode(resp))