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


Python Suggestion.query方法代码示例

本文整理汇总了Python中models.suggestion.Suggestion.query方法的典型用法代码示例。如果您正苦于以下问题:Python Suggestion.query方法的具体用法?Python Suggestion.query怎么用?Python Suggestion.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.suggestion.Suggestion的用法示例。


在下文中一共展示了Suggestion.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        self._require_admin()

        self.template_values['memcache_stats'] = memcache.get_stats()
        self.template_values['databasequery_stats'] = {
            'hits': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_HITS_MEMCACHE_KEYS])),
            'misses': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_MISSES_MEMCACHE_KEYS]))
        }

        # Gets the 5 recently created users
        users = Account.query().order(-Account.created).fetch(5)
        self.template_values['users'] = users

        # Retrieves the number of pending suggestions
        video_suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "match").count()
        self.template_values['video_suggestions'] = video_suggestions

        webcast_suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "event").count()
        self.template_values['webcast_suggestions'] = webcast_suggestions

        media_suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "media").count()
        self.template_values['media_suggestions'] = media_suggestions

        # version info
        try:
            fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')

            with open(fname, 'r') as f:
                data = json.loads(f.read().replace('\r\n', '\n'))

            self.template_values['git_branch_name'] = data['git_branch_name']
            self.template_values['build_time'] = data['build_time']

            commit_parts = re.split("[\n]+", data['git_last_commit'])
            self.template_values['commit_hash'] = commit_parts[0].split(" ")
            self.template_values['commit_author'] = commit_parts[1]
            self.template_values['commit_date'] = commit_parts[2]
            self.template_values['commit_msg'] = commit_parts[3]

        except Exception, e:
            logging.warning("version_info.json parsing failed: %s" % e)
            pass
开发者ID:APerson241,项目名称:the-blue-alliance,代码行数:50,代码来源:admin_main_controller.py

示例2: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        self._require_registration()

        push_sitevar = Sitevar.get_by_id('notifications.enable')
        if push_sitevar is None or not push_sitevar.values_json == "true":
            ping_enabled = "disabled"
        else:
            ping_enabled = ""

        # Compute myTBA statistics
        user = self.user_bundle.account.key
        num_favorites = Favorite.query(ancestor=user).count()
        num_subscriptions = Subscription.query(ancestor=user).count()

        # Compute suggestion statistics
        submissions_pending = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_PENDING, Suggestion.author==user).count()
        submissions_accepted = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_ACCEPTED, Suggestion.author==user).count()

        # Suggestion review statistics
        review_permissions = False
        num_reviewed = 0
        total_pending = 0
        if self.user_bundle.account.permissions:
            review_permissions = True
            num_reviewed = Suggestion.query(Suggestion.reviewer==user).count()
            total_pending = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_PENDING).count()

        # Fetch trusted API keys
        api_keys = ApiAuthAccess.query(ApiAuthAccess.owner == user).fetch()
        write_keys = filter(lambda key: key.is_write_key, api_keys)
        read_keys = filter(lambda key: key.is_read_key, api_keys)

        self.template_values['status'] = self.request.get('status')
        self.template_values['webhook_verification_success'] = self.request.get('webhook_verification_success')
        self.template_values['ping_sent'] = self.request.get('ping_sent')
        self.template_values['ping_enabled'] = ping_enabled
        self.template_values['num_favorites'] = num_favorites
        self.template_values['num_subscriptions'] = num_subscriptions
        self.template_values['submissions_pending'] = submissions_pending
        self.template_values['submissions_accepted'] = submissions_accepted
        self.template_values['review_permissions'] = review_permissions
        self.template_values['num_reviewed'] = num_reviewed
        self.template_values['total_pending'] = total_pending
        self.template_values['read_keys'] = read_keys
        self.template_values['write_keys'] = write_keys
        self.template_values['auth_write_type_names'] = AuthType.write_type_names

        self.response.out.write(jinja2_engine.render('account_overview.html', self.template_values))
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:50,代码来源:account_controller.py

示例3: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        self._require_registration()

        push_sitevar = Sitevar.get_by_id("notifications.enable")
        if push_sitevar is None or not push_sitevar.values_json == "true":
            ping_enabled = "disabled"
        else:
            ping_enabled = ""

        # Compute myTBA statistics
        user = self.user_bundle.account.key
        num_favorites = Favorite.query(ancestor=user).count()
        num_subscriptions = Subscription.query(ancestor=user).count()

        # Compute suggestion statistics
        submissions_pending = Suggestion.query(
            Suggestion.review_state == Suggestion.REVIEW_PENDING, Suggestion.author == user
        ).count()
        submissions_accepted = Suggestion.query(
            Suggestion.review_state == Suggestion.REVIEW_ACCEPTED, Suggestion.author == user
        ).count()

        # Suggestion review statistics
        review_permissions = False
        num_reviewed = 0
        total_pending = 0
        if self.user_bundle.account.permissions:
            review_permissions = True
            num_reviewed = Suggestion.query(Suggestion.reviewer == user).count()
            total_pending = Suggestion.query(Suggestion.review_state == Suggestion.REVIEW_PENDING).count()

        # Fetch trusted API keys
        trusted_keys = ApiAuthAccess.query(ApiAuthAccess.owner == user).fetch()

        self.template_values["status"] = self.request.get("status")
        self.template_values["webhook_verification_success"] = self.request.get("webhook_verification_success")
        self.template_values["ping_enabled"] = ping_enabled
        self.template_values["num_favorites"] = num_favorites
        self.template_values["num_subscriptions"] = num_subscriptions
        self.template_values["submissions_pending"] = submissions_pending
        self.template_values["submissions_accepted"] = submissions_accepted
        self.template_values["review_permissions"] = review_permissions
        self.template_values["num_reviewed"] = num_reviewed
        self.template_values["total_pending"] = total_pending
        self.template_values["trusted_keys"] = trusted_keys
        self.template_values["auth_type_names"] = AuthType.type_names

        self.response.out.write(jinja2_engine.render("account_overview.html", self.template_values))
开发者ID:the-blue-alliance,项目名称:the-blue-alliance,代码行数:50,代码来源:account_controller.py

示例4: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "event_media").fetch(limit=50)

        # Quick and dirty way to group images together
        suggestions = sorted(suggestions, key=lambda x: 0 if x.contents['media_type_enum'] in MediaType.image_types else 1)

        reference_keys = []
        for suggestion in suggestions:
            reference_key = suggestion.contents['reference_key']
            reference = Media.create_reference(
                suggestion.contents['reference_type'],
                reference_key)
            reference_keys.append(reference)

            if 'details_json' in suggestion.contents:
                suggestion.details = json.loads(suggestion.contents['details_json'])
                if 'image_partial' in suggestion.details:
                    suggestion.details['thumbnail'] = suggestion.details['image_partial'].replace('_l', '_m')

        reference_futures = ndb.get_multi_async(reference_keys)
        references = map(lambda r: r.get_result(), reference_futures)

        suggestions_and_references = zip(suggestions, references)

        self.template_values.update({
            "suggestions_and_references": suggestions_and_references,
        })

        self.response.out.write(jinja2_engine.render('suggestions/suggest_event_media_review_list.html', self.template_values))
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:33,代码来源:suggest_event_media_review_controller.py

示例5: createSuggestion

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
 def createSuggestion(self):
     status = SuggestionCreator.createTeamMediaSuggestion(self.account.key,
                                                          'http://imgur.com/foobar',
                                                          'frc1124',
                                                          2016)
     self.assertEqual(status[0], 'success')
     return Suggestion.query().fetch(keys_only=True)[0].id()
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:9,代码来源:test_suggest_team_media_review_controller.py

示例6: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        super(SuggestDesignsReviewController, self).get()
        if self.request.get('action') and self.request.get('id'):
            # Fast-path review
            self._fastpath_review()

        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "robot").fetch(limit=50)

        reference_keys = []
        for suggestion in suggestions:
            reference_key = suggestion.contents['reference_key']
            reference = Media.create_reference(
                suggestion.contents['reference_type'],
                reference_key)
            reference_keys.append(reference)

        reference_futures = ndb.get_multi_async(reference_keys)
        references = map(lambda r: r.get_result(), reference_futures)
        suggestions_and_references = zip(suggestions, references)

        self.template_values.update({
            "suggestions_and_references": suggestions_and_references,
        })

        self.response.out.write(jinja2_engine.render('suggestions/suggest_designs_review.html', self.template_values))
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:29,代码来源:suggest_designs_review_controller.py

示例7: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "event")

        suggestions_by_event_key = {}
        for suggestion in suggestions:
            if 'webcast_dict' in suggestion.contents:
                suggestion.webcast_template = 'webcast/{}.html'.format(suggestion.contents['webcast_dict']['type'])
            suggestions_by_event_key.setdefault(suggestion.target_key, []).append(suggestion)

        suggestion_sets = []
        for event_key, suggestions in suggestions_by_event_key.items():
            suggestion_sets.append({
                "event": Event.get_by_id(event_key),
                "suggestions": suggestions
                })

        self.template_values.update({
            "event_key": self.request.get("event_key"),
            "success": self.request.get("success"),
            "suggestion_sets": suggestion_sets
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_event_webcast_review_list.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:28,代码来源:suggest_event_webcast_review_controller.py

示例8: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        self._require_admin()

        self.template_values['memcache_stats'] = memcache.get_stats()

        # Gets the 5 recently created users
        users = Account.query().order(-Account.created).fetch(5)
        self.template_values['users'] = users

        # Retrieves the number of pending suggestions
        video_suggestions = Suggestion.query().filter(Suggestion.review_state == Suggestion.REVIEW_PENDING).count()
        self.template_values['video_suggestions'] = video_suggestions

        # version info
        try:
            fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')

            with open(fname, 'r') as f:
                data = json.loads(f.read().replace('\r\n', '\n'))

            self.template_values['git_branch_name'] = data['git_branch_name']
            self.template_values['build_time'] = data['build_time']

            commit_parts = re.split("[\n]+", data['git_last_commit'])
            self.template_values['commit_hash'] = commit_parts[0].split(" ")
            self.template_values['commit_author'] = commit_parts[1]
            self.template_values['commit_date'] = commit_parts[2]
            self.template_values['commit_msg'] = commit_parts[3]

        except Exception, e:
            logging.warning("version_info.json parsing failed: %s" % e)
            pass
开发者ID:chrismarra,项目名称:the-blue-alliance,代码行数:34,代码来源:admin_main_controller.py

示例9: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "media")

        reference_keys = []
        for suggestion in suggestions:
            reference_keys.append(Media.create_reference(
                suggestion.contents['reference_type'],
                suggestion.contents['reference_key']))
            if 'details_json' in suggestion.contents:
                suggestion.details = json.loads(suggestion.contents['details_json'])
                if 'image_partial' in suggestion.details:
                    suggestion.details['thumbnail'] = suggestion.details['image_partial'].replace('_l', '_m')

        reference_futures = ndb.get_multi_async(reference_keys)
        references = map(lambda r: r.get_result(), reference_futures)

        suggestions_and_references = zip(suggestions, references)

        self.template_values.update({
            "suggestions_and_references": suggestions_and_references,
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_team_media_review_list.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:hamster1147,项目名称:the-blue-alliance,代码行数:28,代码来源:suggest_team_media_review_controller.py

示例10: test_create_suggestion_banned

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def test_create_suggestion_banned(self):
        status, _ = SuggestionCreator.createOffseasonEventSuggestion(
            self.account_banned.key,
            "Test Event",
            "2016-5-1",
            "2016-5-2",
            "http://foo.bar.com",
            "The Venue",
            "123 Fake Street",
            "New York", "NY", "USA")
        self.assertEqual(status, 'success')

        # Ensure the Suggestion gets created
        suggestions = Suggestion.query().fetch()
        self.assertIsNotNone(suggestions)
        self.assertEqual(len(suggestions), 1)

        suggestion = suggestions[0]
        self.assertIsNotNone(suggestion)
        self.assertEqual(suggestion.contents['name'], "Test Event")
        self.assertEqual(suggestion.contents['start_date'], '2016-5-1')
        self.assertEqual(suggestion.contents['end_date'], '2016-5-2')
        self.assertEqual(suggestion.contents['website'], 'http://foo.bar.com')
        self.assertEqual(suggestion.contents['address'], '123 Fake Street')
        self.assertEqual(suggestion.contents['city'], 'New York')
        self.assertEqual(suggestion.contents['state'], 'NY')
        self.assertEqual(suggestion.contents['country'], 'USA')
        self.assertEqual(suggestion.contents['venue_name'], 'The Venue')
        self.assertEqual(suggestion.review_state, Suggestion.REVIEW_AUTOREJECTED)
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:31,代码来源:test_suggestion_creator.py

示例11: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "offseason-event")

        year = datetime.now().year
        year_events_future = EventListQuery(year).fetch_async()
        last_year_events_future = EventListQuery(year - 1).fetch_async()
        events_and_ids = [self._create_candidate_event(suggestion) for suggestion in suggestions]

        year_events = year_events_future.get_result()
        year_offseason_events = [e for e in year_events if e.event_type_enum == EventType.OFFSEASON]
        last_year_events = last_year_events_future.get_result()
        last_year_offseason_events = [e for e in last_year_events if e.event_type_enum == EventType.OFFSEASON]

        similar_events = [self._get_similar_events(event[1], year_offseason_events) for event in events_and_ids]
        similar_last_year = [self._get_similar_events(event[1], last_year_offseason_events) for event in events_and_ids]

        self.template_values.update({
            'success': self.request.get("success"),
            'event_key': self.request.get("event_key"),
            'events_and_ids': events_and_ids,
            'similar_events': similar_events,
            'similar_last_year': similar_last_year,
        })
        self.response.out.write(
            jinja2_engine.render('suggestions/suggest_offseason_event_review_list.html', self.template_values))
开发者ID:fangeugene,项目名称:the-blue-alliance,代码行数:29,代码来源:suggest_offseason_event_review_controller.py

示例12: test_webcast_good_date

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def test_webcast_good_date(self):
        event = Event(id="2016test", name="Test Event", event_short="Test Event", year=2016, event_type_enum=EventType.OFFSEASON)
        event.put()

        status = SuggestionCreator.createEventWebcastSuggestion(
            self.account.key,
            "http://twitch.tv/frcgamesense",
            "2017-02-28",
            "2016test")

        self.assertEqual(status, 'success')
        suggestions = Suggestion.query().fetch()
        self.assertIsNotNone(suggestions)
        self.assertEqual(len(suggestions), 1)

        suggestion = suggestions[0]

        self.assertIsNotNone(suggestion)
        self.assertEqual(suggestion.target_key, "2016test")
        self.assertEqual(suggestion.author, self.account.key)
        self.assertEqual(suggestion.review_state, Suggestion.REVIEW_PENDING)
        self.assertIsNotNone(suggestion.contents)
        self.assertEqual(suggestion.contents.get('webcast_url'), "http://twitch.tv/frcgamesense")
        self.assertIsNotNone(suggestion.contents.get('webcast_dict'))
        self.assertEqual(suggestion.contents.get('webcast_date'), "2017-02-28")
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:27,代码来源:test_suggestion_creator.py

示例13: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        redirect = self.request.get('redirect')
        if redirect:
            self._require_login(redirect)
        else:
            self._require_login('/account')
        # Redirects to registration page if account not registered
        self._require_registration('/account/register')

        push_sitevar = Sitevar.get_by_id('notifications.enable')
        if push_sitevar is None or not push_sitevar.values_json == "true":
            ping_enabled = "disabled"
        else:
            ping_enabled = ""

        # Compute myTBA statistics
        user = self.user_bundle.account.key
        num_favorites = Favorite.query(ancestor=user).count()
        num_subscriptions = Subscription.query(ancestor=user).count()

        # Compute suggestion statistics
        submissions_pending = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_PENDING, Suggestion.author==user).count()
        submissions_accepted = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_ACCEPTED, Suggestion.author==user).count()

        # Suggestion review statistics
        review_permissions = False
        num_reviewed = 0
        total_pending = 0
        if AccountPermissions.MUTATE_DATA in self.user_bundle.account.permissions:
            review_permissions = True
            num_reviewed = Suggestion.query(Suggestion.reviewer==user).count()
            total_pending = Suggestion.query(Suggestion.review_state==Suggestion.REVIEW_PENDING).count()

        self.template_values['status'] = self.request.get('status')
        self.template_values['webhook_verification_success'] = self.request.get('webhook_verification_success')
        self.template_values['ping_enabled'] = ping_enabled
        self.template_values['num_favorites'] = num_favorites
        self.template_values['num_subscriptions'] = num_subscriptions
        self.template_values['submissions_pending'] = submissions_pending
        self.template_values['submissions_accepted'] = submissions_accepted
        self.template_values['review_permissions'] = review_permissions
        self.template_values['num_reviewed'] = num_reviewed
        self.template_values['total_pending'] = total_pending

        self.response.out.write(jinja2_engine.render('account_overview.html', self.template_values))
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:47,代码来源:account_controller.py

示例14: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        self._require_admin()
        
        suggestions = Suggestion.query().filter(Suggestion.review_state == Suggestion.REVIEW_PENDING)

        self.template_values.update({
            "suggestions": suggestions,
        })
        
        path = os.path.join(os.path.dirname(__file__), '../../../templates/admin/suggestion_list.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:lyncas,项目名称:the-blue-alliance,代码行数:13,代码来源:admin_suggestions_review_controller.py

示例15: get

# 需要导入模块: from models.suggestion import Suggestion [as 别名]
# 或者: from models.suggestion.Suggestion import query [as 别名]
    def get(self):
        suggestions = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).filter(
            Suggestion.target_model == "match").fetch(limit=50)

        self.template_values.update({
            "suggestions": suggestions,
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_match_video_review_list.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:13,代码来源:suggest_match_video_review_controller.py


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