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))
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))
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) if supporter_ids is not None: resp[KEY.STATUS] = 200 resp[KEY.NUM] = len(supporter_ids) self.write(json_encode(resp))
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))