当前位置: 首页>>代码示例>>Python>>正文


Python Event.get_by_id_async方法代码示例

本文整理汇总了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))
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:35,代码来源:suggest_match_video_controller.py

示例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)
开发者ID:NikhilNarayana,项目名称:the-blue-alliance,代码行数:10,代码来源:match_controller.py

示例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")
开发者ID:pyprogrammer,项目名称:the-blue-alliance,代码行数:10,代码来源:match_controller.py

示例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))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:18,代码来源:suggest_match_video_review_controller.py

示例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))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:49,代码来源:admin_cron_controller.py

示例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))
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:20,代码来源:suggest_match_video_controller.py

示例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))
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:21,代码来源:suggest_match_video_controller.py

示例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))
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:25,代码来源:suggest_event_media_controller.py

示例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)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:6,代码来源:event_query.py

示例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)
开发者ID:fangeugene,项目名称:the-blue-alliance,代码行数:7,代码来源:event_query.py


注:本文中的models.event.Event.get_by_id_async方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。