本文整理汇总了Python中corehq.apps.users.models.Invitation.send_activation_email方法的典型用法代码示例。如果您正苦于以下问题:Python Invitation.send_activation_email方法的具体用法?Python Invitation.send_activation_email怎么用?Python Invitation.send_activation_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.users.models.Invitation
的用法示例。
在下文中一共展示了Invitation.send_activation_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invite_web_user
# 需要导入模块: from corehq.apps.users.models import Invitation [as 别名]
# 或者: from corehq.apps.users.models.Invitation import send_activation_email [as 别名]
def invite_web_user(request, domain, template="users/invite_web_user.html"):
role_choices = UserRole.role_choices(domain)
if request.method == "POST":
form = AdminInvitesUserForm(request.POST,
excluded_emails=[user.username for user in WebUser.by_domain(domain)],
role_choices=role_choices
)
if form.is_valid():
data = form.cleaned_data
# create invitation record
data["invited_by"] = request.couch_user.user_id
data["invited_on"] = datetime.utcnow()
data["domain"] = domain
invite = Invitation(**data)
invite.save()
invite.send_activation_email()
messages.success(request, "Invitation sent to %s" % invite.email)
return HttpResponseRedirect(reverse("web_users", args=[domain]))
else:
form = AdminInvitesUserForm(role_choices=role_choices)
context = _users_context(request, domain)
context.update(
registration_form=form
)
return render_to_response(request, template, context)