本文整理汇总了Python中indico.modules.events.registration.models.registrations.Registration.find_all方法的典型用法代码示例。如果您正苦于以下问题:Python Registration.find_all方法的具体用法?Python Registration.find_all怎么用?Python Registration.find_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.registration.models.registrations.Registration
的用法示例。
在下文中一共展示了Registration.find_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_unique_published_registrations
# 需要导入模块: from indico.modules.events.registration.models.registrations import Registration [as 别名]
# 或者: from indico.modules.events.registration.models.registrations.Registration import find_all [as 别名]
def get_unique_published_registrations(event):
"""Get a list of unique published registrations for an event.
Uniqueness is determined by associated user, so if someone has
registered in more than one registration form in the event, they
will be included only once.
:param event: The Event to get registrations for
"""
registrations = Registration.find_all(Registration.is_active,
~RegistrationForm.is_deleted,
RegistrationForm.event_id == event.id,
RegistrationForm.publish_registrations_enabled,
_join=Registration.registration_form)
linked_participants = {reg.user_id: reg for reg in registrations if reg.user_id is not None}
non_linked_participants = {reg for reg in registrations if reg.user_id is None}
return sorted(set(linked_participants.viewvalues()) | non_linked_participants,
key=lambda x: (x.first_name.lower(), x.last_name.lower(), x.id))