本文整理汇总了Python中c3smembership.models.C3sMember.get_invitees方法的典型用法代码示例。如果您正苦于以下问题:Python C3sMember.get_invitees方法的具体用法?Python C3sMember.get_invitees怎么用?Python C3sMember.get_invitees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.models.C3sMember
的用法示例。
在下文中一共展示了C3sMember.get_invitees方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: batch_invite
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_invitees [as 别名]
def batch_invite(request):
"""
Batch invite n members at the same time.
The number (n) is configurable, defaults to 5.
The number can either be supplied in the URL
or by posting a form with 'number' and 'submit to this view.
=== =====================================
URL http://app:port/invite_batch/{number}
=== =====================================
"""
try: # how many to process?
n = int(request.matchdict['number'])
except:
n = 5
if 'submit' in request.POST:
# print("request.POST: {}".format(request.POST))
try:
n = int(request.POST['number'])
except:
n = 5
_invitees = C3sMember.get_invitees(n)
print("got {} invitees".format(len(_invitees)))
if len(_invitees) == 0:
request.session.flash('no invitees left. all done!',
'message_to_staff')
return HTTPFound(request.route_url('toolbox'))
_num_sent = 0
_ids_sent = []
for _m in _invitees:
# prepare a random token iff none is set
if _m.email_invite_token_bcgv16 is None:
_m.email_invite_token_bcgv16 = make_random_token()
_url = (
request.registry.settings['ticketing.url'] +
'/lu/' + _m.email_invite_token_bcgv16 +
'/' + _m.email)
log.info("mailing event invitation to to member id %s" % _m.id)
print("mailing event invitation to member id %s" % _m.id)
email_subject, email_body = make_bcga16_invitation_email(_m, _url)
message = Message(
subject=email_subject,
sender='[email protected]',
recipients=[_m.email],
body=email_body,
extra_headers={
'Reply-To': '[email protected]',
}
)
if 'true' in request.registry.settings[
'testing.mail_to_console']: # pragma: no cover
# ^^ yes, a little ugly, but works; it's a string
# print "printing mail"
# print(message.body.encode('utf-8'))
pass
else:
# print "sending mail"
mailer = get_mailer(request)
mailer.send(message)
# _m._token = _looong_token
_m.email_invite_flag_bcgv16 = True
_m.email_invite_date_bcgv16 = datetime.now()
if _m.membership_accepted and _m.email_invite_flag_bcgv16:
# print("YES!!! updated")
pass
_num_sent += 1
_ids_sent.append(_m.id)
request.session.flash(
"sent out {} mails (to members with ids {}".format(
_num_sent, _ids_sent),
'message_to_staff')
return HTTPFound(request.route_url('toolbox'))