本文整理汇总了Python中indico.modules.groups.models.groups.LocalGroup类的典型用法代码示例。如果您正苦于以下问题:Python LocalGroup类的具体用法?Python LocalGroup怎么用?Python LocalGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalGroup类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_group
def _create_group(id_):
group = LocalGroup()
group.id = id_
group.name = u'dummy-{}'.format(id_)
db.session.add(group)
db.session.flush()
return group.proxy
示例2: migrate_groups
def migrate_groups(self):
print cformat('%{white!}migrating groups')
for old_group in committing_iterator(self.zodb_root['groups'].itervalues()):
if old_group.__class__.__name__ != 'Group':
continue
group = LocalGroup(id=int(old_group.id), name=convert_to_unicode(old_group.name).strip())
print cformat('%{green}+++%{reset} %{white!}{:6d}%{reset} %{cyan}{}%{reset}').format(group.id, group.name)
members = set()
for old_member in old_group.members:
if old_member.__class__.__name__ != 'Avatar':
print cformat('%{yellow!}!!! Unsupported group member type: {}').format(
old_member.__class__.__name__)
continue
user = User.get(int(old_member.id))
if user is None:
print cformat('%{yellow!}!!! User not found: {}').format(old_member.id)
continue
while user.merged_into_user:
user = user.merged_into_user
if user.is_deleted:
print cformat('%{yellow!}!!! User deleted: {}').format(user.id)
continue
members.add(user)
for member in sorted(members, key=attrgetter('full_name')):
print cformat('%{blue!}<->%{reset} %{white!}{:6d} %{yellow}{} ({})').format(
member.id, member.full_name, member.email)
group.members = members
db.session.add(group)
示例3: search
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())
示例4: _checkParams
def _checkParams(self):
if "group_id" in request.view_args:
self.new_group = False
self.group = LocalGroup.get(request.view_args["group_id"])
if self.group is None:
raise NotFound
else:
self.new_group = True
self.group = LocalGroup()
示例5: _process_args
def _process_args(self):
if 'group_id' in request.view_args:
self.new_group = False
self.group = LocalGroup.get(request.view_args['group_id'])
if self.group is None:
raise NotFound
else:
self.new_group = True
self.group = LocalGroup()
示例6: validate_name
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.'))
示例7: group
def group(self):
"""The underlying :class:`.LocalGroup`"""
return LocalGroup.get(self.id)
示例8: has_data
def has_data(self):
return bool(LocalGroup.find().count())