本文整理汇总了Python中indico.modules.events.agreements.models.agreements.Agreement.find方法的典型用法代码示例。如果您正苦于以下问题:Python Agreement.find方法的具体用法?Python Agreement.find怎么用?Python Agreement.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.agreements.models.agreements.Agreement
的用法示例。
在下文中一共展示了Agreement.find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_stats_for_signed_agreements
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import find [as 别名]
def get_stats_for_signed_agreements(cls, event):
"""Returns a digest of signed agreements on an event
:param event: the event
:return: (everybody_signed, num_accepted, num_rejected)
"""
people = cls.get_people(event)
identifiers = [p.identifier for p in people.itervalues()]
query = Agreement.find(Agreement.event_id == event.getId(),
Agreement.type == cls.name,
Agreement.identifier.in_(identifiers))
num_accepted = query.filter(Agreement.accepted).count()
num_rejected = query.filter(Agreement.rejected).count()
everybody_signed = len(people) == (num_accepted + num_rejected)
return everybody_signed, num_accepted, num_rejected
示例2: export_agreements
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import find [as 别名]
def export_agreements(self, aw):
sent_agreements = {a.identifier: a for a in Agreement.find(event_id=self._event.getId(),
type=self._definition.name)}
for person in islice(sorted(self._definition.get_people(self._event).itervalues(),
key=attrgetter('name', 'identifier')),
self._offset, self._offset + self._limit):
agreement = sent_agreements.get(person.identifier)
data = {
'event_id': int(self._event.id),
'identifier': person.identifier,
'sent': agreement is not None,
'accepted': None if (not agreement or agreement.pending) else agreement.accepted,
}
self._definition.extend_api_data(self._event, person, agreement, data)
yield data
示例3: _merge_users
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import find [as 别名]
def _merge_users(target, source, **kwargs):
Agreement.find(user_id=source.id).update({Agreement.user_id: target.id})
示例4: get_people_not_notified
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import find [as 别名]
def get_people_not_notified(cls, event):
"""Returns a dictionary of :class:`AgreementPersonInfo` yet to be notified"""
people = cls.get_people(event)
sent_agreements = {a.identifier for a in Agreement.find(event_id=event.getId(), type=cls.name)}
return {k: v for k, v in people.items() if v.identifier not in sent_agreements}
示例5: _merge_users
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import find [as 别名]
def _merge_users(user, merged, **kwargs):
new_id = int(user.id)
old_id = int(merged.id)
Agreement.find(user_id=old_id).update({'user_id': new_id})