本文整理汇总了Python中dao.Dao.update_region_ranking_criteria方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.update_region_ranking_criteria方法的具体用法?Python Dao.update_region_ranking_criteria怎么用?Python Dao.update_region_ranking_criteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.update_region_ranking_criteria方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import update_region_ranking_criteria [as 别名]
def put(self, region):
dao = Dao(region, mongo_client=mongo_client)
args = rankings_criteria_get_parser.parse_args()
try:
ranking_num_tourneys_attended = int(args['ranking_num_tourneys_attended'])
ranking_activity_day_limit = int(args['ranking_activity_day_limit'])
tournament_qualified_day_limit = int(args['tournament_qualified_day_limit'])
except Exception as e:
return 'Error parsing Ranking Criteria, please try again: ' + str(e), 400
print ranking_num_tourneys_attended
print ranking_activity_day_limit
if not dao:
return 'Dao not found', 404
user = get_user_from_request(request, dao)
if not user:
return 'Permission denied', 403
if not is_user_admin_for_region(user, region):
return 'Permission denied', 403
try:
# TODO Update rankings and store criteria in db
dao.update_region_ranking_criteria(region,
ranking_num_tourneys_attended=ranking_num_tourneys_attended,
ranking_activity_day_limit=ranking_activity_day_limit,
tournament_qualified_day_limit=tournament_qualified_day_limit)
except Exception as e:
print str(e)
return 'There was an error updating the region rankings criteria', 400
return dao.get_region_ranking_criteria(region)
示例2: post
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import update_region_ranking_criteria [as 别名]
def post(self, region):
dao = Dao(region, mongo_client=mongo_client)
args = rankings_criteria_get_parser.parse_args()
if not dao:
return 'Dao not found', 404
user = get_user_from_request(request, dao)
if not user:
return 'Permission denied', 403
if not is_user_admin_for_region(user, region):
return 'Permission denied', 403
# we pass in now so we can mock it out in tests
now = datetime.now()
try:
try:
ranking_num_tourneys_attended = int(args['ranking_num_tourneys_attended'])
ranking_activity_day_limit = int(args['ranking_activity_day_limit'])
tournament_qualified_day_limit = int(args['tournament_qualified_day_limit'])
tournament_id_to_diff = ObjectId(args['tournament_id_to_diff'])
#TODO Get stored rankings from the db
dao.update_region_ranking_criteria(region.lower(),
ranking_num_tourneys_attended=ranking_num_tourneys_attended,
ranking_activity_day_limit=ranking_activity_day_limit,
tournament_qualified_day_limit=tournament_qualified_day_limit)
print 'Running rankings. day_limit: ' + str(ranking_activity_day_limit) + ' and num_tourneys: ' \
+ str(ranking_num_tourneys_attended) + ' and tournament_qualified_day_limit: ' + str(tournament_qualified_day_limit)
tournament_to_diff = dao.get_tournament_by_id(tournament_id_to_diff)
rankings.generate_ranking(dao, now=now,
day_limit=ranking_activity_day_limit,
num_tourneys=ranking_num_tourneys_attended,
tournament_qualified_day_limit=tournament_qualified_day_limit,
tournament_to_diff=tournament_to_diff)
except:
rankings.generate_ranking(dao, now=now)
except Exception as e:
print str(e)
return 'There was an error updating rankings', 400
return self.get(region)