Пример #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]})
			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))
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		result = True
		if KEY.OPERATION in params and params[KEY.OPERATION] == 0:
			result = db.remove_static_relation(params)
		elif KEY.OPERATION in params and params[KEY.OPERATION] == 1:
			result = db.add_static_relation(params)
			'''send the tongtou message to tell the user'''
			user_info = db.get_user_information({KEY.ID: params[KEY.ID]})
			user_acc = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
			
			user_info = utils.trans_unicode_to_utf(user_info)
			user_acc = utils.trans_unicode_to_utf(user_acc)

			mess_package = {KEY.USER_ID: user_info[KEY.ID], KEY.NICKNAME: user_info[KEY.NICKNAME],\
			 KEY.REALNAME: user_info[KEY.NAME], KEY.LOCATION: user_info[KEY.LOCATION], KEY.OCCUPATION: user_info[KEY.OCCUPATION]}
			mess_package[KEY.TYPE] = params[KEY.TYPE]
			mess_package['message-type'] = 4
			if KEY.CONTENT in params:
				mess_package[KEY.CONTENT] = params[KEY.CONTENT]
			
			mess = sendHelp.buildMessage(custom=mess_package)
			print sendHelp.sendEhelp(header + user_acc[KEY.NICKNAME], mess)
		else:
			result = False
		if result:
			resp[KEY.STATUS] = STATUS.OK
		else:
			resp[KEY.STATUS] = STATUS.ERROR

		self.write(json_encode(resp))
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        result = True
        if KEY.OPERATION in params and params[KEY.OPERATION] == 0:
            result = db.remove_static_relation(params)
        elif KEY.OPERATION in params and params[KEY.OPERATION] == 1:
            result = db.add_static_relation(params)
            '''send the tongtou message to tell the user'''
            user_info = db.get_user_information({KEY.ID: params[KEY.ID]})
            user_acc = db.get_user_information({KEY.ID: params[KEY.USER_ID]})

            user_info = utils.trans_unicode_to_utf(user_info)
            user_acc = utils.trans_unicode_to_utf(user_acc)

            mess_package = {KEY.USER_ID: user_info[KEY.ID], KEY.NICKNAME: user_info[KEY.NICKNAME],\
             KEY.REALNAME: user_info[KEY.NAME], KEY.LOCATION: user_info[KEY.LOCATION], KEY.OCCUPATION: user_info[KEY.OCCUPATION]}
            mess_package[KEY.TYPE] = params[KEY.TYPE]
            mess_package['message-type'] = 4
            if KEY.CONTENT in params:
                mess_package[KEY.CONTENT] = params[KEY.CONTENT]

            mess = sendHelp.buildMessage(custom=mess_package)
            print sendHelp.sendEhelp(header + user_acc[KEY.NICKNAME], mess)
        else:
            result = False
        if result:
            resp[KEY.STATUS] = STATUS.OK
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        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])
        supporter_ids = db.list_support_relation(params)
        print supporter_ids
        if supporter_ids is not None:
            supporter_info = []
            for item in supporter_ids:
                user_info = db.get_user_information({KEY.ID: item})
                if user_info is not None:
                    user = {}
                    user[KEY.ID] = user_info[KEY.ID]
                    user[KEY.NICKNAME] = user_info[KEY.NICKNAME]
                    user[KEY.NAME] = user_info[KEY.NAME]
                    user[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
                    user[KEY.REPUTATION] = user_info[KEY.REPUTATION]
                    user[KEY.LOCATION] = user_info[KEY.LOCATION]
                    user[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
                    user[KEY.GENDER] = user_info[KEY.GENDER]
                    supporter_info.append(user)
            resp[KEY.STATUS] = 200
            resp[KEY.INFO] = supporter_info

        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))
Пример #6
0
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        user_info = db.get_user_information(params)
        if user_info is None:
            resp[KEY.STATUS] = STATUS.ERROR
        else:
            user_info[KEY.SUPPORT_NUMBER] = len(
                db.get_join_event_list({KEY.ID: user_info[KEY.ID]}))
            user_info[KEY.LOVE_COIN] = db.get_user_loving_bank(
                {KEY.USER_ID: user_info[KEY.ID]})
            user_info[KEY.MEDICINE_TAKEN] = ""
            user_info[KEY.ANAPHYLAXIS] = ""
            user_info[KEY.MEDICAL_HISTORY] = ""
            health_record = db.get_health_record(user_info[KEY.ID])
            if health_record is not None:
                user_info[KEY.MEDICINE_TAKEN] = health_record[
                    KEY.MEDICINE_TAKEN]
                user_info[KEY.ANAPHYLAXIS] = health_record[KEY.ANAPHYLAXIS]
                user_info[KEY.MEDICAL_HISTORY] = health_record[
                    KEY.MEDICAL_HISTORY]
            resp.update(user_info)
            resp[KEY.STATUS] = STATUS.OK

        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])
        supporter_ids = db.list_support_relation(params)
        print supporter_ids
        if supporter_ids is not None:
            supporter_info = []
            for item in supporter_ids:
                user_info = db.get_user_information({KEY.ID: item})
                if user_info is not None:
                    user = {}
                    user[KEY.ID] = user_info[KEY.ID]
                    user[KEY.NICKNAME] = user_info[KEY.NICKNAME]
                    user[KEY.NAME] = user_info[KEY.NAME]
                    user[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
                    user[KEY.REPUTATION] = user_info[KEY.REPUTATION]
                    user[KEY.LOCATION] = user_info[KEY.LOCATION]
                    user[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
                    user[KEY.GENDER] = user_info[KEY.GENDER]
                    supporter_info.append(user)
            resp[KEY.STATUS] = 200
            resp[KEY.INFO] = supporter_info

        self.write(json_encode(resp))
Пример #8
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))
Пример #9
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.LAUNCHER_ID not in params or KEY.TYPE not in params or 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])
        params[KEY.ID] = int(params[KEY.ID])
        params[KEY.LAUNCHER_ID] = int(params[KEY.LAUNCHER_ID])
        params[KEY.TYPE] = int(params[KEY.TYPE])
        
        flag = db.remove_support_relation(params)
        if flag:
            '''when the event is help or emergence, it is necessary to notify the users'''
            user_info = db.get_user_information({KEY.ID: params[KEY.LAUNCHER_ID]})
            user_info = utils.trans_unicode_to_utf(user_info)
            if user_info is not None:
                if params[KEY.TYPE] == 2:
                    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)
                if params[KEY.TYPE] == 1:
                    mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 0, 6))
                    sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
            resp[KEY.STATUS] = 200

        self.write(json_encode(resp))
Пример #10
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.LAUNCHER_ID not in params or KEY.TYPE 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.LAUNCHER_ID] = int(params[KEY.LAUNCHER_ID])
        params[KEY.TYPE] = int(params[KEY.TYPE])

        flag = db.add_support_relation(params)
        if flag >= 0:
            resp[KEY.STATUS] = 200
            '''send notification to supportee, someone is coming to help him'''
            launcher_info = db.get_user_information({KEY.ID: params[KEY.LAUNCHER_ID]})
            launcher_info = utils.trans_unicode_to_utf(launcher_info)
            if launcher_info is not None:
                if params[KEY.TYPE] == 2:
                    mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 1, 2))
                    sendHelp.sendEhelp(header + launcher_info[KEY.NICKNAME], mess)
                if params[KEY.TYPE] == 1:
                    mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 0, 5))
                    sendHelp.sendEhelp(header + launcher_info[KEY.NICKNAME], mess)


        self.write(json_encode(resp))
Пример #11
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])
        
        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

        self.write(json_encode(resp))
Пример #12
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))
Пример #13
0
 def get(self):
     account = self.get_secure_cookie("username")
     params = {}
     params[KEY.ACCOUNT] = account
     userinfo = db.get_user_information(params)
     newEmail = self.get_argument("email").replace('%40', "@")
     self.render('send-email.html', id=userinfo[KEY.ID], email=newEmail)
Пример #14
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))
Пример #15
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        data[KEY.STATE] = 0
        allRelationUser = db.query_follow(data)
        # print(allRelationUser)
        user_Info = db.get_user_information(data)

        if (allRelationUser != -1):
            family = [
                elem for elem in allRelationUser
                if elem[KEY.RELATION_TYPE] == 0
            ]
            neighbour = [
                elem for elem in allRelationUser
                if elem[KEY.RELATION_TYPE] == 1
            ]
            career = [
                elem for elem in allRelationUser
                if elem[KEY.RELATION_TYPE] == 2
            ]
            # avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png"
            self.render("Ralationship.html",
                        family=family,
                        neighbour=neighbour,
                        career=career)
        else:
            self.write("error")
 def get(self):
     account = self.get_secure_cookie("username")
     params = {}
     params[KEY.ACCOUNT] = account
     userinfo = db.get_user_information(params)
     newEmail = self.get_argument("email").replace('%40', "@")
     self.render('send-email.html', id=userinfo[KEY.ID], email=newEmail)
Пример #17
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))
Пример #18
0
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		
		result = db.handle_static_relation(params)
		if result is True:
			resp[KEY.STATUS] = STATUS.OK
			user_info = db.get_user_information({KEY.ID: params[KEY.ID]})
			user_acc = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
			user_acc = utils.trans_unicode_to_utf(user_acc)
			custom = {'message-type': 5, KEY.STATUS: params[KEY.OPERATION], KEY.NICKNAME: user_info[KEY.NICKNAME]}
			custom = utils.trans_unicode_to_utf(custom)
			mess = sendHelp.buildMessage(custom=custom)
			sendHelp.sendEhelp(KEY.HEADER + user_acc[KEY.NICKNAME], mess)
		else:
			resp[KEY.STATUS] = STATUS.ERROR
    
		self.write(json_encode(resp))
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		
		result = db.handle_static_relation(params)
		if result is True:
			resp[KEY.STATUS] = STATUS.OK
			user_info = db.get_user_information({KEY.ID: params[KEY.ID]})
			user_acc = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
			user_acc = utils.trans_unicode_to_utf(user_acc)
			custom = {'message-type': 5, KEY.STATUS: params[KEY.OPERATION], KEY.NICKNAME: user_info[KEY.NICKNAME]}
			custom = utils.trans_unicode_to_utf(custom)
			mess = sendHelp.buildMessage(custom=custom)
			sendHelp.sendEhelp(KEY.HEADER + user_acc[KEY.NICKNAME], mess)
		else:
			resp[KEY.STATUS] = STATUS.ERROR
    
		self.write(json_encode(resp))
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        user_info = db.get_user_information(params)
        if user_info is None:
            resp[KEY.STATUS] = STATUS.ERROR
        else:
            resp.update(user_info)
            resp[KEY.STATUS] = STATUS.OK

        self.write(json_encode(resp))
 def post(self):
   params = utils.decode_params(self.request)
   resp = {}
   user_info = db.get_user_information(params)
   if user_info is None:
     resp[KEY.STATUS] = STATUS.ERROR
   else:
     resp.update(user_info)
     resp[KEY.STATUS] = STATUS.OK
   
   self.write(json_encode(resp))
Пример #22
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))
    def get(self):
        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)

        if user is not None:
            account = user[KEY.NICKNAME]
            email = user[KEY.EMAIL]
            self.render("changemobile.html", id = id, account = account, email = email)
        else:
            self.write("error")
Пример #24
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        user_Info = db.get_user_information(data)
        if (user_Info is not None):
            reputation = user_Info[KEY.REPUTATION]
            avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png"
            self.render("reputation.html", reputation = reputation, avatar = avatar)
        else:
            self.write("error")
Пример #25
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        user_Info = db.get_user_information(data)
        if (user_Info is not None):
            reputation = user_Info[KEY.REPUTATION]
            avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png"
            self.render("reputation.html", reputation = reputation, avatar = avatar)
        else:
            self.write("error")
Пример #26
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))
Пример #27
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.USER_ID] = int(id)
        bank_Info = db.get_user_loving_bank(data)
        data[KEY.ID] = int(id)
        user_Info = db.get_user_information(data)
        avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png"
        if (bank_Info is not None):
            love_coin = bank_Info[KEY.LOVE_COIN]
            self.render("love_coin.html", love_coin = love_coin, avatar = avatar)
        else:
            self.write("error")
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        user = db.get_user_information(data)
        if (user is not None):
            if user[KEY.EMAIL]:
                email = user[KEY.EMAIL].replace("%40", "@")
            else:
                email = user[KEY.EMAIL]
            self.render("userinfo-modify.html", id = user[KEY.ID], phone = user[KEY.PHONE], email = email, isverified = user[KEY.IS_VERIFY], account=user[KEY.NICKNAME])
        else:
            self.write("error")
Пример #29
0
    def post(self):

        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)
        #加入邮件
        params[KEY.EMAIL] = user[KEY.EMAIL]
        #对图片名称加密
        md5_encode = hashlib.md5()
        md5_encode.update(str(id))
        saveName = md5_encode.hexdigest()

        #saveName = id
        nowpath = os.path.dirname(__file__).replace("handler", "static")
        path = os.path.join(nowpath, "images", "head")
        filepath = uploadImageUtils.uploadImageUtils(self.request, "fileImage",
                                                     saveName, path)

        if filepath:
            params[KEY.NAME] = self.get_argument('realname')

            params[KEY.IDENTITY_ID] = self.get_argument('realID')
            #-----------------------------------------------------
            params[KEY.AVATAR] = saveName + filepath[-4:]

            #防止有人跨过登录这个地址
            while (True):

                idencode = ''.join(random.sample(string.ascii_letters, 4))
                tempParams = {}
                tempParams[KEY.IDENCODE] = idencode
                if db.get_user_verify_info(tempParams) == None:
                    params[KEY.IDENCODE] = idencode
                    break

            verify = db.add_user_verify(params)

            if verify != -1:

                link = "http://120.24.208.130:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                # link = "http://localhost:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                if sendEmail.sendEmailForVerifyUser(params[KEY.NAME],
                                                    params[KEY.IDENTITY_ID],
                                                    filepath, link) == 200:

                    return self.render("comfirm-submit.html", id=id)

        return self.write('error')
Пример #30
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.USER_ID] = int(id)
        bank_Info = db.get_user_loving_bank(data)
        data[KEY.ID] = int(id)
        user_Info = db.get_user_information(data)
        avatar = user_Info[KEY.AVATAR] if user_Info[
            KEY.AVATAR] else "default.png"
        if (bank_Info is not None):
            love_coin = bank_Info[KEY.LOVE_COIN]
            self.render("love_coin.html", love_coin=love_coin, avatar=avatar)
        else:
            self.write("error")
Пример #31
0
    def get(self):
        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)

        if user is not None:
            account = user[KEY.NICKNAME]
            email = user[KEY.EMAIL]
            self.render("changemobile.html",
                        id=id,
                        account=account,
                        email=email)
        else:
            self.write("error")
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        user = db.get_user_information(data)
        if (user is not None):
            email = user[KEY.EMAIL].replace("%40", "@")
            self.render("userinfo-modify.html",
                        id=user[KEY.ID],
                        phone=user[KEY.PHONE],
                        email=email,
                        isverified=user[KEY.IS_VERIFY],
                        account=user[KEY.NICKNAME])
        else:
            self.write("error")
Пример #33
0
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        result = db.get_id_by_phone(params)
        if result is not None:
            resp[KEY.STATUS] = STATUS.OK
            user_info = db.get_user_information({KEY.ID: result})
            resp[KEY.USER_ID] = result
            resp[KEY.NICKNAME] = user_info[KEY.NICKNAME]
            resp[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
            resp[KEY.LOCATION] = user_info[KEY.LOCATION]
            resp[KEY.REPUTATION] = user_info[KEY.REPUTATION]
            resp[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))
    def post(self):
        
        id = self.get_secure_cookie("id")
        params = {}
        params[KEY.ID] = int(id)
        user = db.get_user_information(params)
        #加入邮件
        params[KEY.EMAIL] = user[KEY.EMAIL]
        #对图片名称加密
        md5_encode = hashlib.md5()
        md5_encode.update(str(id))
        saveName = md5_encode.hexdigest()

        #saveName = id
        nowpath = os.path.dirname(__file__).replace("handler", "static")
        path = os.path.join(nowpath, "images", "head")
        filepath = uploadImageUtils.uploadImageUtils(self.request, "fileImage", saveName, path)

        if filepath:
            params[KEY.NAME] = self.get_argument('realname')

            params[KEY.IDENTITY_ID] = self.get_argument('realID')
            #-----------------------------------------------------
            params[KEY.AVATAR] = saveName + filepath[-4:]

            #防止有人跨过登录这个地址
            while (True):

                idencode = ''.join(random.sample(string.ascii_letters, 4))
                tempParams = {}
                tempParams[KEY.IDENCODE] = idencode
                if db.get_user_verify_info(tempParams) == None:
                    params[KEY.IDENCODE] = idencode
                    break

            verify = db.add_user_verify(params)

            if verify != -1:

                link = "http://120.24.208.130:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                # link = "http://localhost:8000/account/userinfo/modify/user_verify_by_email/" + idencode
                if sendEmail.sendEmailForVerifyUser(params[KEY.NAME], params[KEY.IDENTITY_ID], filepath, link) == 200:

                    return self.render("comfirm-submit.html", id=id)

        return self.write('error')
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		result = db.get_id_by_phone(params)
		if result is not None:
			resp[KEY.STATUS] = STATUS.OK
			user_info = db.get_user_information({KEY.ID: result})
			resp[KEY.USER_ID] = result
			resp[KEY.NICKNAME] = user_info[KEY.NICKNAME]
			resp[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
			resp[KEY.LOCATION] = user_info[KEY.LOCATION]
			resp[KEY.REPUTATION] = user_info[KEY.REPUTATION]
			resp[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
		else:
			resp[KEY.STATUS] = STATUS.ERROR
		
		self.write(json_encode(resp))
 def post(self):
   params = utils.decode_params(self.request)
   resp = {}
   user_info = db.get_user_information(params)
   if user_info is None:
     resp[KEY.STATUS] = STATUS.ERROR
   else:
     follow = {}
     follow[KEY.ID] = user_info[KEY.ID]
     follow[KEY.STATE] = 0
     user_info[KEY.FOLLOW] = len(db.query_follow(follow))
     follow[KEY.STATE] = 1
     user_info[KEY.FOLLOWER] = len(db.query_follow(follow))
     resp.update(user_info)
     resp[KEY.STATUS] = STATUS.OK
   
   self.write(json_encode(resp))
Пример #37
0
    def get(self):

        id = self.get_secure_cookie("id")
        data = {}
        data[KEY.ID] = int(id)
        data[KEY.STATE] = 0
        allRelationUser = db.query_follow(data);
        # print(allRelationUser)
        user_Info = db.get_user_information(data)

        if (allRelationUser != -1):
            family = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 0]
            neighbour = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 1]
            career = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 2]
            # avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png"
            self.render("Ralationship.html", family = family, neighbour = neighbour, career = career)
        else:
            self.write("error")
Пример #38
0
    def post(self):
        params = {}
        resp = {KEY.STATUS: 500}
        params = utils.decode_params(self.request)
        if KEY.ID not in params or KEY.TYPE not in params or KEY.LONGITUDE not in params or KEY.LATITUDE not in params:
            self.write(json_encode(resp))
            return
        
        '''trans the term's type'''
        params[KEY.ID] = int(params[KEY.ID])
        params[KEY.LATITUDE] = float(params[KEY.LATITUDE])
        params[KEY.LONGITUDE] = float(params[KEY.LONGITUDE])
        params[KEY.TYPE] = int(params[KEY.TYPE])

        '''add emergent event'''
        flag = db.add_event(params)
        if flag > 0:
            resp[KEY.STATUS] = 200
            resp[KEY.EVENT_ID] = flag
            '''put message to the people nearby'''
            user_list = db.get_nearby_people(params)
            people_nearby_sum = 0
            launcher_info = db.get_user_information({KEY.ID: params[KEY.ID]})
            launcher_info = utils.trans_unicode_to_utf(launcher_info)
            if user_list.count(launcher_info[KEY.NICKNAME]) > 0:
                user_list.remove(launcher_info[KEY.NICKNAME])
                mess = sendHelp.buildMessage(type=1, title=title, content=content1, style=style1)
                sendHelp.sendEhelp(header + launcher_info[KEY.NICKNAME], mess)

            for item in user_list:
                item = item.encode('UTF-8')
                mess = sendHelp.buildMessage(type=1, title=title, content=content, style=style, action=action, custom={KEY.EVENT_ID: flag})    
                sendHelp.sendEhelp(header + item, mess)
                people_nearby_sum += 1
            
            '''
               here we can enhance it, if the people_nearby_sum = 0, we can change the range and send the message
            '''

            '''
               here we can improve it, meanwhile, send message to the emergent contact.
            '''

        self.write(json_encode(resp))
Пример #39
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))
	def post(self):
		params = utils.decode_params(self.request)
		resp = {}
		user_info = db.get_user_information(params)
		if user_info is None:
			resp[KEY.STATUS] = STATUS.ERROR
		else:
			user_info[KEY.SUPPORT_NUMBER] = len(db.get_join_event_list({KEY.ID: user_info[KEY.ID]}))
			user_info[KEY.LOVE_COIN] = db.get_user_loving_bank({KEY.USER_ID: user_info[KEY.ID]})
			user_info[KEY.MEDICINE_TAKEN] = ""
			user_info[KEY.ANAPHYLAXIS] = ""
			user_info[KEY.MEDICAL_HISTORY] = ""
			health_record = db.get_health_record(user_info[KEY.ID])
			if health_record is not None:
				user_info[KEY.MEDICINE_TAKEN] = health_record[KEY.MEDICINE_TAKEN]
				user_info[KEY.ANAPHYLAXIS] = health_record[KEY.ANAPHYLAXIS]
				user_info[KEY.MEDICAL_HISTORY] = health_record[KEY.MEDICAL_HISTORY]
			resp.update(user_info)
			resp[KEY.STATUS] = STATUS.OK
    
		self.write(json_encode(resp))
Пример #41
0
 def Post(self):
     params = utils.decode_params(self.request)
 
     resp = {}
     if KEY.USER_ID not in params:
       temp = db.get_user_information(params)
       if temp is None:
         resp[KEY.STATUS] = STATUS.ERROR
       else:
         resp[KEY.USER_ID] = params[KEY.USER_ID]
         resp[KEY.PASSWORD] = params[KEY.PASSWORD]
 
     else:
       user_id = db.validate_password(params)
       if user_id > 0:
         resp[KEY.STATUS] = STATUS.OK
         resp[KEY.USER_ID] = params[KEY.USER_ID]
       else:
         resp[KEY.STATUS] = STATUS.ERROR
 
     self.write(json_encode(resp))
Пример #42
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.LAUNCHER_ID not in params or KEY.TYPE 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.LAUNCHER_ID] = int(params[KEY.LAUNCHER_ID])
        params[KEY.TYPE] = int(params[KEY.TYPE])

        flag = db.add_support_relation(params)
        if flag >= 0:
            resp[KEY.STATUS] = 200
            '''send notification to supportee, someone is coming to help him'''
            launcher_info = db.get_user_information(
                {KEY.ID: params[KEY.LAUNCHER_ID]})
            launcher_info = utils.trans_unicode_to_utf(launcher_info)
            if launcher_info is not None:
                if params[KEY.TYPE] == 2:
                    mess = sendHelp.buildMessage(type=1,
                                                 title=title,
                                                 content=content,
                                                 style=xinge.Style(
                                                     0, 0, 0, 1, 2))
                    sendHelp.sendEhelp(header + launcher_info[KEY.NICKNAME],
                                       mess)
                if params[KEY.TYPE] == 1:
                    mess = sendHelp.buildMessage(type=1,
                                                 title=title,
                                                 content=content,
                                                 style=xinge.Style(
                                                     0, 0, 0, 0, 5))
                    sendHelp.sendEhelp(header + launcher_info[KEY.NICKNAME],
                                       mess)

        self.write(json_encode(resp))
Пример #43
0
 def get(self):
     account = self.get_secure_cookie("username")
     params = {}
     params[KEY.ACCOUNT] = account
     userinfo = db.get_user_information(params)
     self.render("mobile-success.html", id=userinfo[KEY.ID])
 def get(self):
     account = self.get_secure_cookie("username")
     params = {}
     params[KEY.ACCOUNT] = account
     userinfo = db.get_user_information(params)
     self.render("mobile-success.html", id = userinfo[KEY.ID])
Пример #45
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)
Пример #46
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)