本文整理汇总了Python中indico.modules.events.agreements.models.agreements.Agreement类的典型用法代码示例。如果您正苦于以下问题:Python Agreement类的具体用法?Python Agreement怎么用?Python Agreement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Agreement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reject
def test_reject(reason, on_behalf, expected_state):
ip = '127.0.0.1'
agreement = Agreement()
agreement.reject(from_ip=ip, reason=reason, on_behalf=on_behalf)
assert agreement.state == expected_state
assert agreement.signed_from_ip == ip
assert agreement.reason == reason
assert agreement.signed_dt == now_utc()
agreement.definition.handle_rejected.assert_called_with(agreement)
示例2: test_reset
def test_reset():
agreement = Agreement()
agreement.reset()
assert agreement.state == AgreementState.pending
assert agreement.attachment is None
assert agreement.attachment_filename is None
assert agreement.data is None
assert agreement.reason is None
assert agreement.signed_dt is None
assert agreement.signed_from_ip is None
示例3: _process
def _process(self):
event = self._conf
people = self.definition.get_people(event)
agreements = Agreement.find_all(Agreement.event_id == event.getId(),
Agreement.type == self.definition.name,
Agreement.identifier.in_(people))
return WPAgreementManager.render_template('agreement_type_details.html', event,
event=event, definition=self.definition, agreements=agreements)
示例4: test_create_from_data
def test_create_from_data(dummy_event, dummy_person, dummy_user, person_with_user):
type_ = 'dummy'
dummy_person.user = dummy_user if person_with_user else None
agreement = Agreement.create_from_data(event=dummy_event, type_=type_, person=dummy_person)
assert agreement.event == dummy_event
assert agreement.type == type_
assert agreement.state == AgreementState.pending
assert agreement.uuid
assert agreement.identifier == dummy_person.identifier
assert agreement.person_email == dummy_person.email
assert agreement.person_name == dummy_person.name
assert agreement.user == dummy_person.user
assert agreement.data == dummy_person.data
示例5: export_agreements
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
示例6: _process_args
def _process_args(self):
RHAgreementManagerDetails._process_args(self)
if 'id' in request.view_args:
self.agreement = Agreement.get_one(request.view_args['id'])
if self.event != self.agreement.event:
raise NotFound
if not self.agreement.pending:
raise NoReportError(_("The agreement is already signed"))
else:
self.agreement = None
identifier = request.args['identifier']
try:
self.person = self.definition.get_people(self.event)[identifier]
except KeyError:
raise NotFound
示例7: get_stats_for_signed_agreements
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
示例8: _checkParams
def _checkParams(self, params):
RHAgreementManagerDetails._checkParams(self, params)
if 'id' in request.view_args:
self.agreement = Agreement.find_one(id=request.view_args['id'])
if self._conf != self.agreement.event:
raise NotFound
if not self.agreement.pending:
raise NoReportError(_("The agreement is already signed"))
else:
self.agreement = None
identifier = request.args['identifier']
try:
self.person = self.definition.get_people(self._conf)[identifier]
except KeyError:
raise NotFound
示例9: send_new_agreements
def send_new_agreements(event, name, people, email_body, cc_addresses, from_address):
"""Creates and send agreements for a list of people on a given event.
:param event: The `Event` associated with the agreement
:param name: The agreement type matcing a :class:`AgreementDefinition` name
:param people: The list of people for whom agreements will be created
:param email_body: The body of the email
:param cc_addresses: Email addresses to send CCs to
:param from_address: Email address of the sender
"""
agreements = []
for person in people.itervalues():
agreement = Agreement.create_from_data(event=event, type_=name, person=person)
db.session.add(agreement)
agreements.append(agreement)
db.session.flush()
for agreement in agreements:
notify_agreement_new(agreement, email_body, cc_addresses, from_address)
return agreements
示例10: _get_agreements
def _get_agreements(self):
ids = set(request.form.getlist('references'))
return Agreement.find_all(Agreement.id.in_(ids), Agreement.person_email != None)
示例11: test_is_orphan_no_definition
def test_is_orphan_no_definition(monkeypatch):
monkeypatch.setattr(Agreement, 'definition', property(lambda s: None))
agreement = Agreement()
with pytest.raises(ServiceUnavailable):
agreement.is_orphan()
示例12: test_belongs_to
def test_belongs_to():
agreement = Agreement(identifier='foo')
assert agreement.belongs_to(MagicMock(identifier='foo'))
assert not agreement.belongs_to(MagicMock(identifier='bar'))
示例13: test_is_orphan
def test_is_orphan(dummy_event_new):
agreement = Agreement(event_new=dummy_event_new)
agreement.is_orphan()
agreement.definition.is_agreement_orphan(agreement.event_new, agreement)
示例14: _merge_users
def _merge_users(target, source, **kwargs):
Agreement.find(user_id=source.id).update({Agreement.user_id: target.id})
示例15: test_render
def test_render():
agreement = Agreement()
agreement.render(None)
agreement.definition.render_form.assert_called_with(agreement, None)