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


Python User.find方法代码示例

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


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

示例1: get_queryset

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
 def get_queryset(self):
     log = self.get_log()
     associated_contrib_ids = log.params.get('contributors')
     if associated_contrib_ids is None:
         return []
     associated_users = User.find(Q('_id', 'in', associated_contrib_ids))
     return associated_users
开发者ID:545zhou,项目名称:osf.io,代码行数:9,代码来源:views.py

示例2: update_comments_viewed_timestamp

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def update_comments_viewed_timestamp():
    users = User.find(Q('comments_viewed_timestamp', 'ne', None) | Q('comments_viewed_timestamp', 'ne', {}))
    for user in users:
        if user.comments_viewed_timestamp:
            for node in user.comments_viewed_timestamp:
                user.comments_viewed_timestamp[node] = {'node': user.comments_viewed_timestamp[node]}
            user.save()
            logger.info('Migrated timestamp for user {0}'.format(user._id))
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:10,代码来源:update_comments.py

示例3: test_all_users_have_wiki_osfstorage_enabled

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
    def test_all_users_have_wiki_osfstorage_enabled(self):
        all_user_count = User.find().count()
        results = AddonSnapshot().get_events()
        osfstorage_res = [res for res in results if res['provider']['name'] == 'osfstorage'][0]
        wiki_res = [res for res in results if res['provider']['name'] == 'osfstorage'][0]

        assert_equal(osfstorage_res['users']['enabled'], all_user_count)
        assert_equal(wiki_res['users']['enabled'], all_user_count)
开发者ID:adlius,项目名称:osf.io,代码行数:10,代码来源:test_addon_snapshot.py

示例4: ensure_external_identity_uniqueness

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def ensure_external_identity_uniqueness(provider, identity, user=None):
    from framework.auth.core import User  # avoid circular import

    users_with_identity = User.find(Q('external_identity.{}.{}'.format(provider, identity), 'ne', None))
    for existing_user in users_with_identity:
        if user and user._id == existing_user._id:
            continue
        if existing_user.external_identity[provider][identity] == 'VERIFIED':
            if user and user.external_identity.get(provider, {}).get(identity, {}):
                user.external_identity[provider].pop(identity)
                if user.external_identity[provider] == {}:
                    user.external_identity.pop(provider)
                user.save()  # Note: This won't work in v2 because it rolls back transactions when status >= 400
            raise ValidationError('Another user has already claimed this external identity')
        existing_user.external_identity[provider].pop(identity)
        if existing_user.external_identity[provider] == {}:
            existing_user.external_identity.pop(provider)
        existing_user.save()
    return
开发者ID:monikagrabowska,项目名称:osf.io,代码行数:21,代码来源:utils.py

示例5: test_user_with_claim_url_registers_new_account

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
    def test_user_with_claim_url_registers_new_account(self, mock_session):
        # Assume that the unregistered user data is already stored in the session
        mock_session.data = {
            'unreg_user': {
                'uid': self.user._primary_key,
                'pid': self.project._primary_key,
                'token': self.user.get_unclaimed_record(
                    self.project._primary_key)['token']
            }
        }
        res2 = self.app.get('/account/')
        # Fills in Register form
        form = res2.forms['registerForm']
        form['register-fullname'] = 'tester'
        form['register-username'] = '[email protected]'
        form['register-username2'] = '[email protected]'
        form['register-password'] = 'testing'
        form['register-password2'] = 'testing'
        res3 = form.submit()

        assert_in('Registration successful.', res3.body)
        assert_in('Successfully claimed contributor', res3.body)

        u = User.find(Q('username', 'eq', '[email protected]'))[0]
        key = ApiKeyFactory()
        u.api_keys.append(key)
        u.save()
        u.auth = ('test', key._primary_key)
        self.app.get(u.get_confirmation_url('[email protected]')).follow(auth=u.auth)
        # Confirms their email address
        self.project.reload()
        self.user.reload()
        u.reload()
        assert_not_in(self.user._primary_key, self.project.contributors)
        assert_equal(2, len(self.project.contributors))
        # user is now a contributor to self.project
        assert_in(u._primary_key, self.project.contributors)
开发者ID:lbanner,项目名称:osf.io,代码行数:39,代码来源:webtest_tests.py

示例6: get_queryset

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
 def get_queryset(self):
     return User.find(Q("_id", "eq", self.context["request"].user._id))
开发者ID:cslzchen,项目名称:osf.io,代码行数:4,代码来源:serializers.py

示例7: get_users

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def get_users():
    """Get all users who will be subscribed to the OSF General mailing list."""
    # Exclude unconfirmed and unregistered users
    # NOTE: Unclaimed and unconfirmed users have is_registered=False
    return User.find(Q('is_registered', 'eq', True))
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:sync_email.py

示例8: get_users

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def get_users():
    return User.find(Q('piwik_token', 'eq', None))
开发者ID:545zhou,项目名称:osf.io,代码行数:4,代码来源:ensure_piwik_users.py

示例9: get_targets

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def get_targets():
    """Return a QuerySet containing confirmed Users who have unclaimed records."""
    return User.find(QUERY)
开发者ID:545zhou,项目名称:osf.io,代码行数:5,代码来源:clear_invalid_unclaimed_records.py

示例10: get_targets

# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import find [as 别名]
def get_targets():
    logger.info('Acquiring targets...')
    targets = [u for u in User.find() if Node.find(Q('is_bookmark_collection', 'eq', True) & Q('is_deleted', 'eq', False) & Q('creator', 'eq', u._id)).count() > 1]
    logger.info('Found {} target users.'.format(len(targets)))
    return targets
开发者ID:adlius,项目名称:osf.io,代码行数:7,代码来源:ensure_bookmark_uniqueness_legacy.py


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