本文整理汇总了Python中indico.modules.groups.models.groups.LocalGroup.find方法的典型用法代码示例。如果您正苦于以下问题:Python LocalGroup.find方法的具体用法?Python LocalGroup.find怎么用?Python LocalGroup.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.groups.models.groups.LocalGroup
的用法示例。
在下文中一共展示了LocalGroup.find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from indico.modules.groups.models.groups import LocalGroup [as 别名]
# 或者: from indico.modules.groups.models.groups.LocalGroup import find [as 别名]
def search(cls, name, exact=False, providers=None):
"""Searches for groups
:param name: The group name to search for.
:param exact: If only exact matches should be found (much faster)
:param providers: ``None`` to search in all providers and
local groups. May be a set specifying
providers to search in. For local groups, the
``'indico'`` provider name may be used.
"""
name = name.strip()
if not name:
return []
if exact:
criterion = db.func.lower(LocalGroup.name) == name.lower()
else:
criterion = db.func.lower(LocalGroup.name).contains(name.lower())
result = set()
if providers is None or "indico" in providers:
result |= {g.proxy for g in LocalGroup.find(criterion)}
result |= {
GroupProxy(g.name, g.provider.name, _group=g)
for g in multipass.search_groups(name, providers=providers, exact=exact)
}
return sorted(result, key=lambda x: x.name.lower())
示例2: validate_name
# 需要导入模块: from indico.modules.groups.models.groups import LocalGroup [as 别名]
# 或者: from indico.modules.groups.models.groups.LocalGroup import find [as 别名]
def validate_name(self, field):
query = LocalGroup.find(db.func.lower(LocalGroup.name) == field.data.lower())
if self.group:
query = query.filter(LocalGroup.id != self.group.id)
if query.count():
raise ValidationError(_('A group with this name already exists.'))
示例3: has_data
# 需要导入模块: from indico.modules.groups.models.groups import LocalGroup [as 别名]
# 或者: from indico.modules.groups.models.groups.LocalGroup import find [as 别名]
def has_data(self):
return bool(LocalGroup.find().count())