本文整理汇总了Python中models.event.Event.get_by_id_async方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_by_id_async方法的具体用法?Python Event.get_by_id_async怎么用?Python Event.get_by_id_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.get_by_id_async方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def post(self):
self._require_registration()
event_key = self.request.get("event_key")
if not event_key:
self.response.out.write("No event key found")
return
event_future = Event.get_by_id_async(event_key)
event = event_future.get_result()
if not event:
self.response.out.write("Invalid event key {}".format(event_key))
return
match_futures = Match.query(Match.event == event.key).fetch_async(keys_only=True)
valid_match_keys = [match.id() for match in match_futures.get_result()]
num_videos = int(self.request.get("num_videos", 0))
suggestions_added = 0
for i in range(0, num_videos):
yt_id = self.request.get("video_id_{}".format(i))
match_partial = self.request.get("match_partial_{}".format(i))
if not yt_id or not match_partial:
continue
match_key = "{}_{}".format(event_key, match_partial)
if match_key not in valid_match_keys:
continue
status = SuggestionCreator.createMatchVideoYouTubeSuggestion(self.user_bundle.account.key, yt_id, match_key)
if status == 'success':
suggestions_added += 1
self.redirect('/suggest/event/video?event_key={}&num_added={}'.format(event_key, suggestions_added))
示例2: _render
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def _render(self, match_key):
try:
match_future = Match.get_by_id_async(match_key)
event_future = Event.get_by_id_async(match_key.split("_")[0])
match = match_future.get_result()
event = event_future.get_result()
except Exception, e:
self.abort(404)
示例3: _render
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def _render(self, match_key):
try:
match_future = Match.get_by_id_async(match_key)
event_future = Event.get_by_id_async(match_key.split("_")[0])
match = match_future.get_result()
event = event_future.get_result()
except Exception, e:
return self.redirect("/error/404")
示例4: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def get(self):
suggestions = Suggestion.query().filter(
Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
Suggestion.target_model == "match").fetch(limit=50)
# Roughly sort by event and match for easier review
suggestions = sorted(suggestions, key=lambda s: s.target_key)
event_futures = [Event.get_by_id_async(suggestion.target_key.split("_")[0]) for suggestion in suggestions]
events = [event_future.get_result() for event_future in event_futures]
self.template_values.update({
"suggestions_and_events": zip(suggestions, events),
})
self.response.out.write(jinja2_engine.render('suggestions/suggest_match_video_review_list.html', self.template_values))
示例5: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def get(self, event_key):
# Fetch for later
event_future = Event.get_by_id_async(event_key)
matches_future = match_query.EventMatchesQuery(event_key).fetch_async()
# Rebuild event teams
taskqueue.add(
url='/tasks/math/do/eventteam_update/' + event_key,
method='GET')
# Create Winner/Finalist awards for offseason events
awards = []
event = event_future.get_result()
if event.event_type_enum in {EventType.OFFSEASON, EventType.FOC}:
matches = MatchHelper.organizeMatches(matches_future.get_result())
bracket = MatchHelper.generateBracket(matches, event, event.alliance_selections)
if 'f' in bracket:
winning_alliance = '{}_alliance'.format(bracket['f'][1]['winning_alliance'])
if winning_alliance == 'red_alliance':
losing_alliance = 'blue_alliance'
else:
losing_alliance = 'red_alliance'
awards.append(Award(
id=Award.render_key_name(event.key_name, AwardType.WINNER),
name_str="Winner",
award_type_enum=AwardType.WINNER,
year=event.year,
event=event.key,
event_type_enum=event.event_type_enum,
team_list=[ndb.Key(Team, 'frc{}'.format(team)) for team in bracket['f'][1][winning_alliance] if team.isdigit()],
recipient_json_list=[json.dumps({'team_number': team, 'awardee': None}) for team in bracket['f'][1][winning_alliance]],
))
awards.append(Award(
id=Award.render_key_name(event.key_name, AwardType.FINALIST),
name_str="Finalist",
award_type_enum=AwardType.FINALIST,
year=event.year,
event=event.key,
event_type_enum=event.event_type_enum,
team_list=[ndb.Key(Team, 'frc{}'.format(team)) for team in bracket['f'][1][losing_alliance] if team.isdigit()],
recipient_json_list=[json.dumps({'team_number': team, 'awardee': None}) for team in bracket['f'][1][losing_alliance]],
))
AwardManipulator.createOrUpdate(awards)
self.response.out.write("Finished post-event tasks for {}. Created awards: {}".format(event_key, awards))
示例6: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def get(self):
self._require_registration()
if not self.request.get("event_key"):
self.redirect("/", abort=True)
event_future = Event.get_by_id_async(self.request.get("event_key"))
event = event_future.get_result()
if not event:
self.abort(404)
self.template_values.update({
"event": event,
"num_added": self.request.get("num_added")
})
self.response.out.write(jinja2_engine.render('suggestions/suggest_match_video_playlist.html', self.template_values))
示例7: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def get(self):
self._require_login("/suggest/match/video?match=%s" % self.request.get("match_key"))
if not self.request.get("match_key"):
self.redirect("/", abort=True)
match_future = Match.get_by_id_async(self.request.get("match_key"))
event_future = Event.get_by_id_async(self.request.get("match_key").split("_")[0])
match = match_future.get_result()
event = event_future.get_result()
self.template_values.update({
"success": self.request.get("success"),
"event": event,
"match": match,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_match_video.html')
self.response.out.write(template.render(path, self.template_values))
示例8: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def get(self):
self._require_registration()
if not self.request.get("event_key"):
self.redirect("/", abort=True)
event_future = Event.get_by_id_async(self.request.get("event_key"))
event = event_future.get_result()
if not event:
self.abort(404)
medias_future = EventMediasQuery(event.key_name).fetch_async()
medias = medias_future.get_result()
medias_by_slugname = MediaHelper.group_by_slugname(medias)
self.template_values.update({
"status": self.request.get("status"),
"medias_by_slugname": medias_by_slugname,
"event": event,
})
self.response.out.write(jinja2_engine.render('suggestions/suggest_event_media.html', self.template_values))
示例9: _query_async
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def _query_async(self):
event_key = self._query_args[0]
event = yield Event.get_by_id_async(event_key)
raise ndb.Return(event)
示例10: _query_async
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import get_by_id_async [as 别名]
def _query_async(self):
event_key = self._query_args[0]
event = yield Event.get_by_id_async(event_key)
divisions = yield ndb.get_multi_async(event.divisions)
raise ndb.Return(divisions)