本文整理汇总了Python中indico.modules.events.models.principals.EventPrincipal.has_management_permission方法的典型用法代码示例。如果您正苦于以下问题:Python EventPrincipal.has_management_permission方法的具体用法?Python EventPrincipal.has_management_permission怎么用?Python EventPrincipal.has_management_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.models.principals.EventPrincipal
的用法示例。
在下文中一共展示了EventPrincipal.has_management_permission方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_has_management_permission_explicit_fail
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def test_has_management_permission_explicit_fail():
p = EventPrincipal(permissions=['foo'])
# no permission specified
with pytest.raises(ValueError):
p.has_management_permission(explicit=True)
with pytest.raises(ValueError):
EventPrincipal.has_management_permission(explicit=True)
示例2: test_has_management_permission_explicit
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def test_has_management_permission_explicit(explicit):
p = EventPrincipal(full_access=True, permissions=['foo'])
assert p.has_management_permission('foo', explicit=explicit)
assert p.has_management_permission('ANY', explicit=explicit)
assert p.has_management_permission('bar', explicit=explicit) == (not explicit)
assert (EventPrincipal(full_access=True, permissions=[]).has_management_permission('ANY', explicit=explicit) ==
(not explicit))
示例3: _process
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def _process(self):
event_principal_query = (EventPrincipal.query.with_parent(self.event)
.filter(EventPrincipal.type == PrincipalType.email,
EventPrincipal.has_management_permission('submit')))
contrib_principal_query = (ContributionPrincipal.find(Contribution.event == self.event,
ContributionPrincipal.type == PrincipalType.email,
ContributionPrincipal.has_management_permission('submit'))
.join(Contribution)
.options(contains_eager('contribution')))
session_principal_query = (SessionPrincipal.find(Session.event == self.event,
SessionPrincipal.type == PrincipalType.email,
SessionPrincipal.has_management_permission())
.join(Session).options(joinedload('session').joinedload('acl_entries')))
persons = self.get_persons()
person_list = sorted(persons.viewvalues(), key=lambda x: x['person'].display_full_name.lower())
num_no_account = 0
for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
if principal.email not in persons:
continue
if not persons[principal.email].get('no_account'):
persons[principal.email]['roles']['no_account'] = True
num_no_account += 1
custom_roles = {'custom_{}'.format(r.id): {'name': r.name, 'code': r.code, 'color': r.color}
for r in self.event.roles}
return WPManagePersons.render_template('management/person_list.html', self.event, persons=person_list,
num_no_account=num_no_account, builtin_roles=BUILTIN_ROLES,
custom_roles=custom_roles)
示例4: get_events_managed_by
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def get_events_managed_by(user, dt=None):
"""Gets the IDs of events where the user has management privs.
:param user: A `User`
:param dt: Only include events taking place on/after that date
:return: A set of event ids
"""
query = (user.in_event_acls
.join(Event)
.options(noload('user'), noload('local_group'), load_only('event_id'))
.filter(~Event.is_deleted, Event.ends_after(dt))
.filter(EventPrincipal.has_management_permission('ANY')))
return {principal.event_id for principal in query}
示例5: get_events_with_paper_roles
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def get_events_with_paper_roles(user, dt=None):
"""
Get the IDs and PR roles of events where the user has any kind
of paper reviewing privileges.
:param user: A `User`
:param dt: Only include events taking place on/after that date
:return: A dict mapping event IDs to a set of roles
"""
paper_permissions = {'paper_manager', 'paper_judge', 'paper_content_reviewer', 'paper_layout_reviewer'}
role_criteria = [EventPrincipal.has_management_permission(permission, explicit=True)
for permission in paper_permissions]
query = (user.in_event_acls
.join(Event)
.options(noload('user'), noload('local_group'), load_only('event_id', 'permissions'))
.filter(~Event.is_deleted, Event.ends_after(dt))
.filter(db.or_(*role_criteria)))
return {principal.event_id: set(principal.permissions) & paper_permissions for principal in query}
示例6: _find
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def _find(*args):
return EventPrincipal.find(EventPrincipal.event == event, EventPrincipal.has_management_permission(*args))
示例7: test_has_management_permission
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def test_has_management_permission():
p = EventPrincipal(permissions=['foo'])
assert p.has_management_permission('ANY')
assert p.has_management_permission('foo')
assert not p.has_management_permission('bar')
示例8: test_has_management_permission_no_access
# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import has_management_permission [as 别名]
def test_has_management_permission_no_access():
p = EventPrincipal(read_access=True, permissions=[])
assert not p.has_management_permission()
assert not p.has_management_permission('foo')
assert not p.has_management_permission('ANY')