本文整理汇总了Python中indico.modules.events.agreements.models.agreements.Agreement.create_from_data方法的典型用法代码示例。如果您正苦于以下问题:Python Agreement.create_from_data方法的具体用法?Python Agreement.create_from_data怎么用?Python Agreement.create_from_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.agreements.models.agreements.Agreement
的用法示例。
在下文中一共展示了Agreement.create_from_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_from_data
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import create_from_data [as 别名]
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
示例2: _process
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import create_from_data [as 别名]
def _process(self):
event = self._conf
agreement = self.agreement
form = AgreementAnswerSubmissionForm()
if form.validate_on_submit():
if agreement is None:
agreement = Agreement.create_from_data(event=self._conf, type_=self.definition.name, person=self.person)
db.session.add(agreement)
db.session.flush()
if form.answer.data:
agreement.accept(from_ip=request.remote_addr, on_behalf=True)
agreement.attachment_filename = form.document.data.filename
agreement.attachment = form.document.data.read()
else:
agreement.reject(from_ip=request.remote_addr, on_behalf=True)
flash(_("Agreement answered on behalf of {0}".format(agreement.person_name)), 'success')
return jsonify(success=True)
return WPJinjaMixin.render_template('events/agreements/dialogs/agreement_submit_answer_form.html', form=form,
event=event, agreement=agreement)
示例3: send_new_agreements
# 需要导入模块: from indico.modules.events.agreements.models.agreements import Agreement [as 别名]
# 或者: from indico.modules.events.agreements.models.agreements.Agreement import create_from_data [as 别名]
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