本文整理汇总了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
示例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))
示例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)
示例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
示例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)
示例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))
示例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))
示例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))
示例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)
示例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