예제 #1
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.LONGITUDE not in params or KEY.LATITUDE not in params:
            self.write(json_encode(resp))
            return

        '''trans the term's type'''
        params[KEY.LONGITUDE] = float(params[KEY.LONGITUDE])
        params[KEY.LATITUDE] = float(params[KEY.LATITUDE])
        params[KEY.STATE] = 0
        event_id_list = db.get_nearby_event_by_location(params)
        if event_id_list is not None:
            event_list = []
            for item in event_id_list:
                event_info = db.get_event_information({KEY.EVENT_ID: item})
                if event_info is not None:
                    event_temp = {}
                    event_temp[KEY.EVENT_ID] = event_info[KEY.EVENT_ID]
                    event_temp[KEY.TYPE] = event_info[KEY.TYPE]
                    event_temp[KEY.LONGITUDE] = event_info[KEY.LONGITUDE]
                    event_temp[KEY.LATITUDE] = event_info[KEY.LATITUDE]
                    event_list.append(event_temp)
            resp[KEY.STATUS] = 200
            resp[KEY.INFO] = event_list

        self.write(json_encode(resp))
예제 #2
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))
예제 #3
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return
        
        '''trans the term's type'''
        params[KEY.ID] = int(params[KEY.ID])
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])

        event_info = db.get_event_information(params)
        if event_info is not None:
            if event_info[KEY.LAUNCHER_ID] == params[KEY.ID]:
                resp[KEY.STATUS] = 200

                params[KEY.STATE] = 1
                if not db.update_event(params):
                    resp[KEY.STATUS] = 500
                else:
                    '''send a notification to notice the user. all supporters'''
                    supporter_ids = db.list_support_relation({KEY.EVENT_ID: params[KEY.EVENT_ID]})
                    if supporter_ids is not None:
                        resp[KEY.STATUS] = 200
                        for item in supporter_ids:
                            user_info = db.get_user_information({KEY.ID: item})
                            user_info = utils.trans_unicode_to_utf(user_info)
                            mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 1, 3))
                            sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
                            mess = sendHelp.buildMessage(custom={'message-type': 2})
                            sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)

        self.write(json_encode(resp))
예제 #4
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return
        '''trans the term's type'''
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
        event_info = db.get_event_information(params)
        if event_info is not None:
            resp[KEY.STATUS] = 200
            resp[KEY.LAUNCHER_ID] = event_info[KEY.LAUNCHER_ID]
            resp[KEY.TIME] = event_info[KEY.TIME]
            resp[KEY.TYPE] = int(event_info[KEY.TYPE])
            resp[KEY.SUPPORT_NUMBER] = event_info[KEY.SUPPORT_NUMBER]
            resp[KEY.DEMAND_NUMBER] = event_info[KEY.DEMAND_NUMBER]
            resp[KEY.LONGITUDE] = event_info[KEY.LONGITUDE]
            resp[KEY.LATITUDE] = event_info[KEY.LATITUDE]
            resp[KEY.LAUNCHER_NAME] = event_info[KEY.LAUNCHER]
            user = db.get_user_information({KEY.ID: resp[KEY.LAUNCHER_ID]})
            if user is not None:
                resp[KEY.CONTACT] = user[KEY.PHONE]
                resp[KEY.GENDER] = user[KEY.GENDER]
                resp[KEY.REPUTATION] = user[KEY.REPUTATION]
            '''if this event is help'''
            if resp[KEY.TYPE] == 1:
                resp[KEY.TITLE] = event_info[KEY.TITLE]
                resp[KEY.CONTENT] = event_info[KEY.CONTENT]
                resp[KEY.LOVE_COIN] = int(event_info[KEY.LOVE_COIN])

        self.write(json_encode(resp))
예제 #5
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return

        '''trans the term's type'''
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
        event_info = db.get_event_information(params)
        if event_info is not None:
            resp[KEY.STATUS] = 200
            resp[KEY.LAUNCHER_ID] = event_info[KEY.LAUNCHER_ID]
            resp[KEY.TIME] = event_info[KEY.TIME]
            resp[KEY.TYPE] = int(event_info[KEY.TYPE])
            resp[KEY.SUPPORT_NUMBER] = event_info[KEY.SUPPORT_NUMBER]
            resp[KEY.DEMAND_NUMBER] = event_info[KEY.DEMAND_NUMBER]
            resp[KEY.LONGITUDE] = event_info[KEY.LONGITUDE]
            resp[KEY.LATITUDE] = event_info[KEY.LATITUDE]
            resp[KEY.LAUNCHER_NAME] = event_info[KEY.LAUNCHER]
            user = db.get_user_information({KEY.ID: resp[KEY.LAUNCHER_ID]})
            if user is not None:
                resp[KEY.CONTACT] = user[KEY.PHONE]

            '''if this event is help'''
            if resp[KEY.TYPE] == 1:
                resp[KEY.TITLE] = event_info[KEY.TITLE]
                resp[KEY.CONTENT] = event_info[KEY.CONTENT]
                resp[KEY.LOVE_COIN] = int(event_info[KEY.LOVE_COIN])

        self.write(json_encode(resp))
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return
        '''trans the term's type'''
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
        launcher_info = db.get_event_information(params)
        if launcher_info is not None:
            user_info = db.get_user_information(
                {KEY.ID: launcher_info[KEY.LAUNCHER_ID]})
            if user_info is not None:
                resp[KEY.STATUS] = 200
                resp[KEY.ID] = user_info[KEY.ID]
                resp[KEY.NICKNAME] = user_info[KEY.NICKNAME]
                resp[KEY.NAME] = user_info[KEY.NAME]
                resp[KEY.AGE] = user_info[KEY.AGE]
                resp[KEY.GENDER] = user_info[KEY.GENDER]
                resp[KEY.PHONE] = user_info[KEY.PHONE]
                resp[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
                resp[KEY.REPUTATION] = user_info[KEY.REPUTATION]
                resp[KEY.LOCATION] = user_info[KEY.LOCATION]
                resp[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]

        self.write(json_encode(resp))
예제 #7
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return

        '''trans the term's type'''
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
        launcher_info = db.get_event_information(params)
        if launcher_info is not None:
            user_info = db.get_user_information({KEY.ID: launcher_info[KEY.LAUNCHER_ID]})
            if user_info is not None:
                resp[KEY.STATUS] = 200
                resp[KEY.ID] = user_info[KEY.ID]
                resp[KEY.NICKNAME] = user_info[KEY.NICKNAME]
                resp[KEY.NAME] = user_info[KEY.NAME]
                resp[KEY.AGE] = user_info[KEY.AGE]
                resp[KEY.GENDER] = user_info[KEY.GENDER]
                resp[KEY.PHONE] = user_info[KEY.PHONE]
                resp[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
                resp[KEY.REPUTATION] = user_info[KEY.REPUTATION]
                resp[KEY.LOCATION] = user_info[KEY.LOCATION]
                resp[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]

        self.write(json_encode(resp))
예제 #8
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.LONGITUDE not in params or KEY.LATITUDE not in params:
            self.write(json_encode(resp))
            return
        '''trans the term's type'''
        params[KEY.LONGITUDE] = float(params[KEY.LONGITUDE])
        params[KEY.LATITUDE] = float(params[KEY.LATITUDE])
        params[KEY.STATE] = 0
        event_id_list = db.get_nearby_event_by_location(params)
        if event_id_list is not None:
            event_list = []
            for item in event_id_list:
                event_info = db.get_event_information({KEY.EVENT_ID: item})
                if event_info is not None:
                    event_temp = {}
                    event_temp[KEY.EVENT_ID] = event_info[KEY.EVENT_ID]
                    event_temp[KEY.TYPE] = event_info[KEY.TYPE]
                    event_temp[KEY.LONGITUDE] = event_info[KEY.LONGITUDE]
                    event_temp[KEY.LATITUDE] = event_info[KEY.LATITUDE]
                    event_list.append(event_temp)
            resp[KEY.STATUS] = 200
            resp[KEY.INFO] = event_list

        self.write(json_encode(resp))
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        event_info = db.get_event_information(params)
        if event_info is None:
            resp[KEY.STATUS] = STATUS.ERROR
        else:
            resp.update(event_info)
            resp[KEY.STATUS] = STATUS.OK

        self.write(json_encode(resp))
  def post(self):
    params = utils.decode_params(self.request)
    resp = {}
    event_info = db.get_event_information(params)
    if event_info is None:
      resp[KEY.STATUS] = STATUS.ERROR
    else:
      resp.update(event_info)
      resp[KEY.STATUS] = STATUS.OK

    self.write(json_encode(resp))
  def post(self):
    params = utils.decode_params(self.request)

    resp = {}
    resp = db.get_event_information(params)
    if resp is None:
      print "resp is None"
      resp = {}
      resp[KEY.STATUS] = STATUS.ERROR
    else:
      resp[KEY.STATUS] = STATUS.OK

    self.write(json_encode(resp))
예제 #12
0
    def post(self):
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.EVENT_ID not in params or KEY.ANSWER_ID not in params:
            self.write(json_encode(resp))
            return

        resp = {}
        params[KEY.IS_ADOPTED] = 1
        result = db.update_answer(params)
        if result is True:
            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]})
            answer_info = db.get_answer_info(
                {KEY.ANSWER_ID: params[KEY.ANSWER_ID]})
            user_info = utils.trans_unicode_to_utf(user_info)
            event_info = utils.trans_unicode_to_utf(event_info)
            answer_info = utils.trans_unicode_to_utf(answer_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.LAUNCHER: answer_info[KEY.AUTHOR].encode('UTF-8'), \
            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'] = 7
            mess = sendHelp.buildMessage(type=1,
                                         title=title,
                                         content=content,
                                         style=style,
                                         action=action,
                                         custom=custom)
            sendHelp.sendEhelp(
                header + answer_info[KEY.AUTHOR].encode('UTF-8'), mess)

            mess = sendHelp.buildMessage(custom=custom)
            sendHelp.sendEhelp(
                header + answer_info[KEY.AUTHOR].encode('UTF-8'), mess)

        else:
            resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))
예제 #13
0
 def post(self):
   params = utils.decode_params(self.request)
   
   resp = {}
   event_id = db.add_event(params)
   if event_id > 0:
     event_info = {}
     event_info[KEY.EVENT_ID] = event_id
     resp = db.get_event_information(event_info)
     if resp is None:
       resp = {}      
     resp[KEY.STATUS] = STATUS.OK
   else:
     resp[KEY.STATUS] = STATUS.ERROR
   
   self.write(json_encode(resp))
예제 #14
0
    def post(self):
        params = utils.decode_params(self.request)

        resp = {}
        event_id = db.add_event(params)
        if event_id > 0:
            event_info = {}
            event_info[KEY.EVENT_ID] = event_id
            resp = db.get_event_information(event_info)
            if resp is None:
                resp = {}
            resp[KEY.STATUS] = STATUS.OK
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))
예제 #15
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.EVENT_ID not in params:
            self.write(json_encode(resp))
            return
        '''trans the term's type'''
        params[KEY.ID] = int(params[KEY.ID])
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])

        event_info = db.get_event_information(params)
        if event_info is not None:
            if event_info[KEY.LAUNCHER_ID] == params[KEY.ID]:
                resp[KEY.STATUS] = 200

            params[KEY.STATE] = 2
            if not db.update_event(params):
                resp[KEY.STATUS] = 500
            else:
                '''send notification to the people who is coming to help him'''
                supporter_ids = db.list_support_relation(
                    {KEY.EVENT_ID: params[KEY.EVENT_ID]})
                if supporter_ids is not None:
                    for item in supporter_ids:
                        user_info = db.get_user_information({KEY.ID: item})
                        user_info = utils.trans_unicode_to_utf(user_info)
                        if user_info is not None:
                            mess = sendHelp.buildMessage(
                                type=1,
                                title=title,
                                content=content,
                                style=style,
                                custom={KEY.EVENT_ID: params[KEY.EVENT_ID]})

                            sendHelp.sendEhelp(
                                header + user_info[KEY.NICKNAME], mess)
                            '''send tongtou message to android'''
                            mess = sendHelp.buildMessage(
                                custom={'message-type': 3})
                            sendHelp.sendEhelp(
                                header + user_info[KEY.NICKNAME], mess)

        self.write(json_encode(resp))
예제 #16
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.EVENT_ID not in params or KEY.USER_ID not in params or KEY.VALUE not in params:
            self.write(json_encode(resp))
            return
        '''trans the term's type'''
        params[KEY.ID] = int(params[KEY.ID])
        params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
        params[KEY.USER_ID] = int(params[KEY.USER_ID])
        params[KEY.VALUE] = float(params[KEY.VALUE])

        event_info = db.get_event_information(
            {KEY.EVENT_ID: params[KEY.EVENT_ID]})

        flag = db.evaluate_user(params)
        if flag:
            '''we can import here, use some algorithm to incease the helper's reputation'''
            user = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
            if user is not None:
                reputation = user[KEY.REPUTATION]
                params[KEY.VALUE] = reputation * (
                    1 - VALUE.RATE) + VALUE.RATE * params[KEY.VALUE]
                if db.update_user({
                        KEY.ID: params[KEY.USER_ID],
                        KEY.REPUTATION: params[KEY.VALUE]
                }):
                    resp[KEY.STATUS] = 200
                '''
                update_info = {}
                update_info[KEY.ID] = params[KEY.USER_ID]
                update_info[KEY.OPERATION] = 0
                update_info[KEY.LOVE_COIN] = event_info[KEY.LOVE_COIN]
                update_info[KEY.SCORE] = 5

                if db.update_loving_bank(update_info):
                    if resp[KEY.STATUS] == 200:
                        resp[KEY.STATUS] = 200
                '''

        self.write(json_encode(resp))
예제 #17
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))
예제 #18
0
  def post(self):
    params = utils.decode_params(self.request)
    
    resp = {}
    event_id = db.add_event(params)
    print "From add_event_handler: event id: %d"%event_id
    if event_id > 0:
      # update location in Baidu LBS Cloud
      baiduResult = baidulbs.update_location(params, KEY.EVENT)

      event_info = {}
      event_info[KEY.EVENT_ID] = event_id
      resp = db.get_event_information(event_info)
      if resp is None:
        resp = {}
      else:
        #print resp
        # get a near users' id list of current event
        near_list = baidulbs.get_user_location(resp)
        # get correspond push_token to user id
        token_list = db.get_push_token(near_list)

        # if there are tokens, push to those user
        if token_list is not None or token_list != []:
          if resp[KEY.TYPE] == 1:
            title = "New Help"
            activity = ""
            content = resp[KEY.CONTENT]
            utils.push_message(title, content, event_id, KEY.SENDALL, token_list)
          elif resp[KEY.TYPE] == 2:
            title = "New SOS"
            activity = ""
            content = resp[KEY.CONTENT]
            utils.push_message(title, content, event_id, KEY.SENDALL, token_list)
      resp[KEY.STATUS] = STATUS.OK
    else:
      resp[KEY.STATUS] = STATUS.ERROR
    
    self.write(json_encode(resp))
예제 #19
0
    def get(self):
        '''----------------------------------------------------------------------------------'''
        '''----------------search the nearby event from the database-------------------------'''
        '''----------------------------------------------------------------------------------'''
        userId = self.get_secure_cookie("id")
        eventData = {}
        frontDesk = {}
        frontDesk["quesEvent"] = []
        frontDesk["helpEvent"] = []
        frontDesk["saveEvent"] = []

        eventData[KEY.ID] = int(userId)

        #注意项目中的事件信息和评论的区别
        #事件是每个有标题有内容的大部分
        #评论是每个事件下面的小部分内容
        '''get question event infomation------start-----'''
        eventData[KEY.TYPE] = 0

        quesTempData = db.get_nearby_event(eventData)
        if len(quesTempData) > 5:
            quesTempData = quesTempData[0:5]
        for item in quesTempData:
            data = {}
            data[KEY.EVENT_ID] = item

            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[
                KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[
                KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]
            eventInfo["eventinfos"]["love_coin"] = eventAllInfo[KEY.LOVE_COIN]
            '''get event comments information'''
            eventInfo["comments"] = []
            eventAllComs = db.get_comments(data)
            eventInfo["comments_num"] = len(eventAllComs)
            for item in eventAllComs:
                temp = {}

                commenterProfile = db.get_user_extra_information(
                    int(item[KEY.AUTHOR_ID]))
                if commenterProfile["name"] != None:
                    fout = open(
                        'static/images/head/' + commenterProfile["name"], 'wb')

                    #数据库里面可以存一个图片的或者其他类型的二进制文件,把数据库
                    #里面的数据读到图片文件中
                    fout.write(commenterProfile["profile"])
                    fout.close()
                else:
                    commenterProfile["name"] = "default.png"

                #-----------------------debug--------------------------

                commenterAvatar = db.get_user_information(
                    {"id": int(item[KEY.AUTHOR_ID])})
                # if commenterAvatar[KEY.IS_VERIFY] == 1:
                if commenterAvatar[KEY.IS_VERIFY] == 1:

                    #print commenterAvatar[KEY.AVATAR]
                    commenterProfile["name"] = commenterAvatar[KEY.AVATAR]

                #------------------------------------------------------

                temp["comment_pic_src"] = commenterProfile["name"]
                temp["comment_author"] = item[KEY.AUTHOR]
                temp["comment_content"] = item[KEY.CONTENT]
                temp["comment_time"] = item[KEY.TIME]
                eventInfo["comments"].append(temp)

            #获得事件发起人的信息,event_id是整个事件的信息,
            #里面的launcher_id为发起人的id
            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information(
                {KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[
                KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[
                KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[
                KEY.IS_VERIFY]
            #add-------------------------------
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[
                    KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"
            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(
                int(eventAllInfo[KEY.LAUNCHER_ID]))
            if launcherExtraInfo["name"] != None:
                fout = open('static/images/head/' + launcherExtraInfo["name"],
                            'wb')
                fout.write(launcherExtraInfo["profile"])
                fout.close()
            else:
                launcherExtraInfo["name"] = "default.png"

            #-----------------------------debug--------------------------
            if userAllInfo[KEY.IS_VERIFY]:
                launcherExtraInfo["name"] = userAllInfo[KEY.AVATAR]

            #-----------------------------------------------------------

            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo[
                "name"]

            frontDesk["quesEvent"].append(eventInfo)
        '''get question event infomation-----end------'''
        '''get help event information-----start------'''
        eventData[KEY.TYPE] = 1
        helpTempData = db.get_nearby_event(eventData)
        if len(helpTempData) > 5:
            helpTempData = helpTempData[0:5]

        for item in helpTempData:
            data = {}
            data[KEY.EVENT_ID] = item

            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[
                KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[
                KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]
            eventInfo["eventinfos"]["love_coin"] = eventAllInfo[KEY.LOVE_COIN]

            eventInfo["eventinfos"]["event_state"] = eventAllInfo[KEY.STATE]
            eventInfo["eventinfos"]["event_longitude"] = eventAllInfo[
                KEY.LONGITUDE]
            eventInfo["eventinfos"]["event_latitude"] = eventAllInfo[
                KEY.LATITUDE]
            eventInfo["eventinfos"]["event_follower_num"] = eventAllInfo[
                KEY.FOLLOW_NUMBER]
            eventInfo["eventinfos"]["event_supporter_num"] = eventAllInfo[
                KEY.SUPPORT_NUMBER]
            eventInfo["eventinfos"]["event_location"] = eventAllInfo[
                KEY.LOCATION]
            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information(
                {KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[
                KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[
                KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[
                KEY.IS_VERIFY]

            #add-------------------------------
            # eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[KEY.AVATAR]
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[
                    KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"
            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(
                int(eventAllInfo[KEY.LAUNCHER_ID]))
            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo[
                "profile"]

            frontDesk["helpEvent"].append(eventInfo)
        '''get help event information-----end-----'''
        '''get save event information-----start---'''
        eventData[KEY.TYPE] = 2

        saveTempData = db.get_nearby_event(eventData)
        if len(saveTempData) > 5:
            saveTempData = saveTempData[0:5]
        for item in saveTempData:
            data = {}
            data[KEY.EVENT_ID] = item

            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[
                KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[
                KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]

            eventInfo["eventinfos"]["event_state"] = eventAllInfo[KEY.STATE]
            eventInfo["eventinfos"]["event_longitude"] = eventAllInfo[
                KEY.LONGITUDE]
            eventInfo["eventinfos"]["event_latitude"] = eventAllInfo[
                KEY.LATITUDE]
            eventInfo["eventinfos"]["event_follower_num"] = eventAllInfo[
                KEY.FOLLOW_NUMBER]
            eventInfo["eventinfos"]["event_supporter_num"] = eventAllInfo[
                KEY.SUPPORT_NUMBER]
            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information(
                {KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[
                KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[
                KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[
                KEY.IS_VERIFY]
            #add-------------------------------
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[
                    KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"
            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(
                int(eventAllInfo[KEY.LAUNCHER_ID]))
            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo[
                "profile"]

            frontDesk["saveEvent"].append(eventInfo)
        '''get save event information----end------'''
        '''----------------------------------------------------------------------------------'''
        '''----------------current user information from the database------------------------'''
        '''----------------------------------------------------------------------------------'''
        frontDesk["currentUserInfo"] = {}
        userBasicInfo = db.get_user_information({KEY.ID: int(userId)})
        frontDesk["currentUserInfo"]["user_nickname"] = userBasicInfo[
            KEY.NICKNAME]
        userExtraInfo = db.get_user_extra_information(int(userId))
        frontDesk["currentUserInfo"]["user_profile"] = userExtraInfo["profile"]
        frontDesk["currentUserInfo"]["user_concernNum"] = userExtraInfo[
            "concernNum"]
        frontDesk["currentUserInfo"]["user_checkIn"] = userExtraInfo["checkIn"]

        userBankInfo = db.get_user_loving_bank({"user_id": int(userId)})
        frontDesk["currentUserInfo"]["user_score"] = userBankInfo[KEY.SCORE]
        frontDesk["currentUserInfo"]["user_checkIn"] = userBankInfo[
            KEY.LOVE_COIN]
        '''----------------------------------------------------------------------------------'''
        '''----------------current user record information from the database-----------------'''
        '''----------------------------------------------------------------------------------'''
        frontDesk["currentUserRecordInfo"] = {}
        '''for question event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["question"] = {}
        question_launch_event_list = db.get_launch_event_list({
            KEY.ID:
            int(userId),
            KEY.TYPE:
            0
        })
        frontDesk["currentUserRecordInfo"]["question"]["ask_num"] = len(
            question_launch_event_list)
        frontDesk["currentUserRecordInfo"]["question"]["ask_date"] = []
        for item in question_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["question"]["ask_date"].append(
                tempEventInfo["time"])

        question_reply_time_list = db.get_comment_by_id({KEY.ID: int(userId)})
        frontDesk["currentUserRecordInfo"]["question"]["reply_num"] = len(
            question_reply_time_list)
        frontDesk["currentUserRecordInfo"]["question"][
            "reply_date"] = question_reply_time_list
        '''for question event's data-------------end--------------'''
        '''for help event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["help"] = {}
        help_launch_event_list = db.get_launch_event_list({
            KEY.ID: int(userId),
            KEY.TYPE: 1
        })
        frontDesk["currentUserRecordInfo"]["help"]["ask_num"] = len(
            help_launch_event_list)
        frontDesk["currentUserRecordInfo"]["help"]["ask_date"] = []
        for item in help_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["help"]["ask_date"].append(
                tempEventInfo["time"])

        help_reply_time_list = db.get_support_time({
            KEY.ID: int(userId),
            KEY.TYPE: 2,
            "event_type": 1
        })
        frontDesk["currentUserRecordInfo"]["help"]["reply_num"] = len(
            help_reply_time_list)
        frontDesk["currentUserRecordInfo"]["help"][
            "reply_date"] = help_reply_time_list
        '''for help event's data---end----'''
        '''for save event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["save"] = {}
        save_launch_event_list = db.get_launch_event_list({
            KEY.ID: int(userId),
            KEY.TYPE: 2
        })
        frontDesk["currentUserRecordInfo"]["save"]["ask_num"] = len(
            save_launch_event_list)
        frontDesk["currentUserRecordInfo"]["save"]["ask_date"] = []
        for item in save_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["save"]["ask_date"].append(
                tempEventInfo["time"])

        save_reply_time_list = db.get_support_time({
            KEY.ID: int(userId),
            KEY.TYPE: 2,
            "event_type": 2
        })
        frontDesk["currentUserRecordInfo"]["save"]["reply_num"] = len(
            save_reply_time_list)
        frontDesk["currentUserRecordInfo"]["save"][
            "reply_date"] = save_reply_time_list
        '''for save event's data---end----'''

        #self.write(frontDesk)
        userInfo = db.get_user_information(eventData)
        if userInfo[KEY.EMAIL]:
            userInfo[KEY.EMAIL] = userInfo[KEY.EMAIL].replace("%40", "@")
        self.render('information.html',
                    userId=userId,
                    userName=self.current_user,
                    disData=frontDesk,
                    userInfo=userInfo)
예제 #20
0
    def get(self):
        '''----------------------------------------------------------------------------------'''
    	'''----------------search the nearby event from the database-------------------------'''
        '''----------------------------------------------------------------------------------'''
        userId = self.get_secure_cookie("id")
    	eventData = {}
        frontDesk = {}
        frontDesk["quesEvent"] =  []
        frontDesk["helpEvent"] = []
        frontDesk["saveEvent"] = []

    	eventData[KEY.ID] = int(userId)

        #注意项目中的事件信息和评论的区别
        #事件是每个有标题有内容的大部分
        #评论是每个事件下面的小部分内容
        '''get question event infomation------start-----'''
    	eventData[KEY.TYPE] = 0

        quesTempData = db.get_nearby_event(eventData)
        if len(quesTempData) > 5:
            quesTempData = quesTempData[0:5]
    	for item in quesTempData:
            data = {}
            data[KEY.EVENT_ID] = item
            
            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]
            eventInfo["eventinfos"]["love_coin"] = eventAllInfo[KEY.LOVE_COIN]

            '''get event comments information'''
            eventInfo["comments"] = []
            eventAllComs = db.get_comments(data)
            eventInfo["comments_num"] = len(eventAllComs)
            for item in eventAllComs:
                temp = {}

                commenterProfile = db.get_user_extra_information(int(item[KEY.AUTHOR_ID]))
                if commenterProfile["name"] != None:
                    fout = open('static/images/head/' + commenterProfile["name"], 'wb')

                    #数据库里面可以存一个图片的或者其他类型的二进制文件,把数据库
                    #里面的数据读到图片文件中
                    fout.write(commenterProfile["profile"])
                    fout.close()
                else:
                    commenterProfile["name"] = "default.png"

                #-----------------------debug--------------------------

                commenterAvatar = db.get_user_information({"id":int(item[KEY.AUTHOR_ID])})
                # if commenterAvatar[KEY.IS_VERIFY] == 1:
                if commenterAvatar[KEY.IS_VERIFY] == 1:

                    #print commenterAvatar[KEY.AVATAR]
                    commenterProfile["name"] = commenterAvatar[KEY.AVATAR]

                #------------------------------------------------------


                temp["comment_pic_src"] = commenterProfile["name"]
                temp["comment_author"] = item[KEY.AUTHOR]
                temp["comment_content"] = item[KEY.CONTENT]
                temp["comment_time"] = item[KEY.TIME]
                eventInfo["comments"].append(temp)

            
            #获得事件发起人的信息,event_id是整个事件的信息,
            #里面的launcher_id为发起人的id    
            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information({KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[KEY.IS_VERIFY]
            #add-------------------------------
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"




            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(int(eventAllInfo[KEY.LAUNCHER_ID]))
            if launcherExtraInfo["name"] != None:
                fout = open('static/images/head/' + launcherExtraInfo["name"], 'wb')
                fout.write(launcherExtraInfo["profile"])
                fout.close()
            else:
                launcherExtraInfo["name"] = "default.png"


            #-----------------------------debug--------------------------
            if userAllInfo[KEY.IS_VERIFY]:
                launcherExtraInfo["name"] = userAllInfo[KEY.AVATAR]







            #-----------------------------------------------------------



            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo["name"]

            frontDesk["quesEvent"].append(eventInfo)

        '''get question event infomation-----end------'''

        '''get help event information-----start------'''
        eventData[KEY.TYPE] = 1
        helpTempData = db.get_nearby_event(eventData)
        if len(helpTempData) > 5:
            helpTempData = helpTempData[0:5]

        for item in helpTempData:
            data = {}
            data[KEY.EVENT_ID] = item
            
            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]
            eventInfo["eventinfos"]["love_coin"] = eventAllInfo[KEY.LOVE_COIN]

            eventInfo["eventinfos"]["event_state"] = eventAllInfo[KEY.STATE]
            eventInfo["eventinfos"]["event_longitude"] = eventAllInfo[KEY.LONGITUDE]
            eventInfo["eventinfos"]["event_latitude"] = eventAllInfo[KEY.LATITUDE]
            eventInfo["eventinfos"]["event_follower_num"] = eventAllInfo[KEY.FOLLOW_NUMBER]
            eventInfo["eventinfos"]["event_supporter_num"] = eventAllInfo[KEY.SUPPORT_NUMBER]
            eventInfo["eventinfos"]["event_location"] = eventAllInfo[KEY.LOCATION]

            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information({KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[KEY.IS_VERIFY]

            #add-------------------------------
            # eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[KEY.AVATAR]
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"


            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(int(eventAllInfo[KEY.LAUNCHER_ID]))
            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo["profile"]

            frontDesk["helpEvent"].append(eventInfo)
        '''get help event information-----end-----'''


        '''get save event information-----start---'''
        eventData[KEY.TYPE] = 2

        saveTempData = db.get_nearby_event(eventData)
        if len(saveTempData) > 5:
            saveTempData = saveTempData[0:5]
        for item in saveTempData:
            data = {}
            data[KEY.EVENT_ID] = item
            
            eventInfo = {}
            eventAllInfo = db.get_event_information(data)
            '''get event information'''
            eventInfo["eventinfos"] = {}
            eventInfo["eventinfos"]["event_id"] = eventAllInfo[KEY.EVENT_ID]
            eventInfo["eventinfos"]["launcher_id"] = eventAllInfo[KEY.LAUNCHER_ID]
            eventInfo["eventinfos"]["event_title"] = eventAllInfo[KEY.TITLE]
            eventInfo["eventinfos"]["event_content"] = eventAllInfo[KEY.CONTENT]
            eventInfo["eventinfos"]["event_time"] = eventAllInfo[KEY.TIME]

            eventInfo["eventinfos"]["event_state"] = eventAllInfo[KEY.STATE]
            eventInfo["eventinfos"]["event_longitude"] = eventAllInfo[KEY.LONGITUDE]
            eventInfo["eventinfos"]["event_latitude"] = eventAllInfo[KEY.LATITUDE]
            eventInfo["eventinfos"]["event_follower_num"] = eventAllInfo[KEY.FOLLOW_NUMBER]
            eventInfo["eventinfos"]["event_supporter_num"] = eventAllInfo[KEY.SUPPORT_NUMBER]

            '''get launcher information'''
            eventInfo["launcherinfos"] = {}
            userAllInfo = db.get_user_information({KEY.ID: eventAllInfo[KEY.LAUNCHER_ID]})
            eventInfo["launcherinfos"]["launcher_nickname"] = userAllInfo[KEY.NICKNAME]
            eventInfo["launcherinfos"]["launcher_reputation"] = userAllInfo[KEY.REPUTATION]
            eventInfo["launcherinfos"]["launcher_type"] = userAllInfo[KEY.TYPE]
            eventInfo["launcherinfos"]["launcher_isverify"] = userAllInfo[KEY.IS_VERIFY]
            #add-------------------------------
            if userAllInfo[KEY.AVATAR] is not None:
                eventInfo["launcherinfos"]["launcher_avatar"] = userAllInfo[KEY.AVATAR]
            else:
                eventInfo["launcherinfos"]["launcher_avatar"] = "default.png"



            '''get launcher profile'''
            launcherExtraInfo = db.get_user_extra_information(int(eventAllInfo[KEY.LAUNCHER_ID]))
            eventInfo["launcherinfos"]["launcher_profile"] = launcherExtraInfo["profile"]

            frontDesk["saveEvent"].append(eventInfo)

        '''get save event information----end------'''

        '''----------------------------------------------------------------------------------'''
        '''----------------current user information from the database------------------------'''
        '''----------------------------------------------------------------------------------'''
        frontDesk["currentUserInfo"] = {}
        userBasicInfo = db.get_user_information({KEY.ID: int(userId)})
        frontDesk["currentUserInfo"]["user_nickname"] = userBasicInfo[KEY.NICKNAME]
        userExtraInfo = db.get_user_extra_information(int(userId))
        frontDesk["currentUserInfo"]["user_profile"] = userExtraInfo["profile"]
        frontDesk["currentUserInfo"]["user_concernNum"] = userExtraInfo["concernNum"]
        frontDesk["currentUserInfo"]["user_checkIn"] = userExtraInfo["checkIn"]

        userBankInfo = db.get_user_loving_bank({"user_id": int(userId)})
        frontDesk["currentUserInfo"]["user_score"] = userBankInfo[KEY.SCORE]
        frontDesk["currentUserInfo"]["user_checkIn"] = userBankInfo[KEY.LOVE_COIN]


        '''----------------------------------------------------------------------------------'''
        '''----------------current user record information from the database-----------------'''
        '''----------------------------------------------------------------------------------'''
        frontDesk["currentUserRecordInfo"] = {}
        '''for question event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["question"] = {}
        question_launch_event_list = db.get_launch_event_list({KEY.ID: int(userId), KEY.TYPE: 0})
        frontDesk["currentUserRecordInfo"]["question"]["ask_num"] = len(question_launch_event_list)
        frontDesk["currentUserRecordInfo"]["question"]["ask_date"] = []
        for item in question_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["question"]["ask_date"].append(tempEventInfo["time"])

        question_reply_time_list = db.get_comment_by_id({KEY.ID: int(userId)})        
        frontDesk["currentUserRecordInfo"]["question"]["reply_num"] = len(question_reply_time_list)
        frontDesk["currentUserRecordInfo"]["question"]["reply_date"] = question_reply_time_list
        '''for question event's data-------------end--------------'''

        '''for help event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["help"] = {}
        help_launch_event_list = db.get_launch_event_list({KEY.ID: int(userId), KEY.TYPE: 1})
        frontDesk["currentUserRecordInfo"]["help"]["ask_num"] = len(help_launch_event_list)
        frontDesk["currentUserRecordInfo"]["help"]["ask_date"] = []
        for item in help_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["help"]["ask_date"].append(tempEventInfo["time"])

        help_reply_time_list = db.get_support_time({KEY.ID: int(userId), KEY.TYPE: 2, "event_type": 1})        
        frontDesk["currentUserRecordInfo"]["help"]["reply_num"] = len(help_reply_time_list)
        frontDesk["currentUserRecordInfo"]["help"]["reply_date"] = help_reply_time_list
        '''for help event's data---end----'''

        '''for save event's data-------------start------------'''
        frontDesk["currentUserRecordInfo"]["save"] = {}
        save_launch_event_list = db.get_launch_event_list({KEY.ID: int(userId), KEY.TYPE: 2})
        frontDesk["currentUserRecordInfo"]["save"]["ask_num"] = len(save_launch_event_list)
        frontDesk["currentUserRecordInfo"]["save"]["ask_date"] = []
        for item in save_launch_event_list:
            tempEventInfo = db.get_event_information({KEY.EVENT_ID: item})
            frontDesk["currentUserRecordInfo"]["save"]["ask_date"].append(tempEventInfo["time"])

        save_reply_time_list = db.get_support_time({KEY.ID: int(userId), KEY.TYPE: 2, "event_type": 2})        
        frontDesk["currentUserRecordInfo"]["save"]["reply_num"] = len(save_reply_time_list)
        frontDesk["currentUserRecordInfo"]["save"]["reply_date"] = save_reply_time_list
        '''for save event's data---end----'''

        #self.write(frontDesk)
        userInfo = db.get_user_information(eventData)
        if userInfo[KEY.EMAIL]:
            userInfo[KEY.EMAIL] = userInfo[KEY.EMAIL].replace("%40", "@")
        self.render('information.html', userId=userId, userName = self.current_user, disData = frontDesk, userInfo = userInfo)
        #self.render('demo.html', userId=userId, userName = self.current_user, eventInfo = frontDesk)