當前位置: 首頁>>代碼示例>>Python>>正文


Python Invitation.send_activation_email方法代碼示例

本文整理匯總了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)
開發者ID:mchampanis,項目名稱:core-hq,代碼行數:27,代碼來源:views.py


注:本文中的corehq.apps.users.models.Invitation.send_activation_email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。