本文整理汇总了Python中dao.Dao.insert_pending_merge方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.insert_pending_merge方法的具体用法?Python Dao.insert_pending_merge怎么用?Python Dao.insert_pending_merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.insert_pending_merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_pending_merge [as 别名]
def post(self, region):
dao = Dao(region, mongo_client=mongo_client)
requesting_user = get_user_from_access_token(request.headers, dao)
if not requesting_user.admin_regions: #wow, such auth
return "user is not an admin", 403
args = merges_put_parser.parse_args() #parse args
try:
base_player_id = ObjectId(args['base_player_id'])
to_be_merged_player_id = ObjectId(args['to_be_merged_player_id'])
except:
return "invalid ids, that wasn't an ObjectID", 400
# the above should validate that we have real objectIDs
# now lets validate that both of those players exist
if not dao.get_player_by_id(base_player_id):
return "base_player not found", 400
if not dao.get_player_by_id(to_be_merged_player_id):
return "to_be_merged_player not found", 400
#get curr time
now = datetime.now()
#create a new merge object
the_merge = Merge(requesting_user.id, base_player_id, to_be_merged_player_id, now)
#store it in the dao
merge_id = dao.insert_pending_merge(the_merge)
string_rep = str(merge_id)
return_dict = {'id': string_rep}
return return_dict, 200
示例2: post
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_pending_merge [as 别名]
def post(self, region):
dao = Dao(region, mongo_client=mongo_client)
user = get_user_from_request(request, dao)
if not user:
return 'Permission denied', 403
if not user.admin_regions: #wow, such auth -- fixed, now we actually do more auth checking later
return "user is not an admin", 403
args = merges_put_parser.parse_args() #parse args
try:
base_player_id = ObjectId(args['base_player_id'])
to_be_merged_player_id = ObjectId(args['to_be_merged_player_id'])
except:
return "invalid ids, that wasn't an ObjectID", 400
# the above should validate that we have real objectIDs
# now lets validate that both of those players exist
player1 = dao.get_player_by_id(base_player_id)
if not player1:
return "base_player not found", 400
player2 = dao.get_player_by_id(to_be_merged_player_id)
if not player2:
return "to_be_merged_player not found", 400
if not is_user_admin_for_regions(user, player1.regions):
return "Permission denied", 403
if not is_user_admin_for_regions(user, player2.regions):
return "Permission denied", 403
#get curr time
now = datetime.now()
#create a new merge object
the_merge = Merge(requesting_user.id, base_player_id, to_be_merged_player_id, now)
#store it in the dao
merge_id = dao.insert_pending_merge(the_merge)
string_rep = str(merge_id)
return_dict = {'id': string_rep}
return return_dict, 200