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


Python Invitation.save方法代碼示例

本文整理匯總了Python中corehq.apps.users.models.Invitation.save方法的典型用法代碼示例。如果您正苦於以下問題:Python Invitation.save方法的具體用法?Python Invitation.save怎麽用?Python Invitation.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在corehq.apps.users.models.Invitation的用法示例。


在下文中一共展示了Invitation.save方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: invite_web_user

# 需要導入模塊: from corehq.apps.users.models import Invitation [as 別名]
# 或者: from corehq.apps.users.models.Invitation import save [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

示例2: setUpClass

# 需要導入模塊: from corehq.apps.users.models import Invitation [as 別名]
# 或者: from corehq.apps.users.models.Invitation import save [as 別名]
 def setUpClass(cls):
     cls.invitations = []
     for kwargs in [
         {'domain': 'domain_1', 'email': '[email protected]'},
         {'domain': 'domain_1', 'email': '[email protected]', 'is_accepted': True},
         {'domain': 'domain_2', 'email': '[email protected]'},
     ]:
         inv = Invitation(**kwargs)
         inv.save()
         cls.invitations.append(inv)
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:12,代碼來源:test_models.py


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