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))
    def post(self):
        params = utils.decode_params(self.request)

        resp = {}
        if KEY.OPERATION not in params:
            resp[KEY.STATUS] = STATUS.ERROR
        elif params[KEY.OPERATION] == 0:
            if db.remove_static_relation(params):
                resp[KEY.STATUS] = STATUS.OK
            else:
                resp[KEY.STATUS] = STATUS.ERROR
        elif params[KEY.OPERATION] == 1:
            if db.add_static_relation(params):
                resp[KEY.STATUS] = STATUS.OK
            else:
                resp[KEY.STATUS] = STATUS.ERROR
        elif params[KEY.OPERATION] == 2:
            resp[KEY.USER_LIST] = db.query_follow(params)
            if resp[KEY.USER_LIST] == -1:
                resp[KEY.STATUS] = STATUS.ERROR
            else:
                resp[KEY.STATUS] = STATUS.OK
        elif params[KEY.OPERATION] == 3:
            relation = db.get_relation(params)
            if relation == -1:
                resp[KEY.STATUS] = STATUS.ERROR
            else:
                resp[KEY.TYPE] = relation
                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 = {}
   if KEY.OPERATION not in params:
     resp[KEY.STATUS] = STATUS.ERROR
   elif params[KEY.OPERATION] == 0:
     if db.remove_static_relation(params):
       resp[KEY.STATUS] = STATUS.OK
     else:
       resp[KEY.STATUS] = STATUS.ERROR
   elif params[KEY.OPERATION] == 1:
     if db.add_static_relation(params):
       resp[KEY.STATUS] = STATUS.OK
     else:
       resp[KEY.STATUS] = STATUS.ERROR
   elif params[KEY.OPERATION] == 2:
     resp[KEY.USER_LIST] = db.query_follow(params)
     if resp[KEY.USER_LIST] == -1:
       resp[KEY.STATUS] = STATUS.ERROR
     else:
       resp[KEY.STATUS] = STATUS.OK
   elif params[KEY.OPERATION] == 3:
     relation = db.get_relation(params)
     if relation == -1:
       resp[KEY.STATUS] = STATUS.ERROR
     else:
       resp[KEY.TYPE] = relation
       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 = {}
   if KEY.OPERATION not in params:
     resp[KEY.STATUS] = STATUS.ERROR
   elif params[KEY.OPERATION] == 0:
     if db.remove_static_relation(params):
       resp[KEY.STATUS] = STATUS.OK
     else:
       resp[KEY.STATUS] = STATUS.ERROR
   elif params[KEY.OPERATION] == 1:
     if db.add_static_relation(params):
       resp[KEY.STATUS] = STATUS.OK
     else:
       resp[KEY.STATUS] = STATUS.ERROR
   else:
     resp[KEY.STATUS] = STATUS.ERROR
   
   self.write(json_encode(resp))
    def post(self):
        params = utils.decode_params(self.request)

        resp = {}
        if KEY.OPERATION not in params:
            resp[KEY.STATUS] = STATUS.ERROR
        elif params[KEY.OPERATION] == 0:
            if db.remove_static_relation(params):
                resp[KEY.STATUS] = STATUS.OK
            else:
                resp[KEY.STATUS] = STATUS.ERROR
        elif params[KEY.OPERATION] == 1:
            if db.add_static_relation(params):
                resp[KEY.STATUS] = STATUS.OK
            else:
                resp[KEY.STATUS] = STATUS.ERROR
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))