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


Python RegistrationRequest.tos_confirmed方法代碼示例

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


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

示例1: request_new_domain

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import tos_confirmed [as 別名]
def request_new_domain(request, form, org, new_user=True):
    now = datetime.utcnow()

    dom_req = RegistrationRequest()
    if new_user:
        dom_req.tos_confirmed = form.cleaned_data['tos_confirmed']
        dom_req.request_time = now
        dom_req.request_ip = get_ip(request)
        dom_req.activation_guid = uuid.uuid1().hex

    if org:
        new_domain = Domain(slug=form.cleaned_data['domain_name'],
                            is_active=False,
                            date_created=datetime.utcnow(), organization=org)
    else:
        new_domain = Domain(name=form.cleaned_data['domain_name'],
                            is_active=False,
                            date_created=datetime.utcnow())

    if not new_user:
        new_domain.is_active = True

    new_domain.save()
    if not new_domain.name:
        new_domain.name = new_domain._id
        new_domain.save() # we need to get the name from the _id

    dom_req.domain = new_domain.name

    if request.user.is_authenticated():
        current_user = CouchUser.from_django_user(request.user)
        if not current_user:
            current_user = WebUser()
            current_user.sync_from_django_user(request.user)
            current_user.save()
        current_user.add_domain_membership(new_domain.name, is_admin=True)
        current_user.save()
        dom_req.requesting_user_username = request.user.username
        dom_req.new_user_username = request.user.username

    if new_user:
        dom_req.save()
        send_domain_registration_email(request.user.email,
                                       dom_req.domain,
                                       dom_req.activation_guid)
    else:
        send_global_domain_registration_email(request.user, new_domain.name)
    send_new_domain_request_update_email(request.user, get_ip(request), new_domain.name, is_new_user=new_user)
開發者ID:mchampanis,項目名稱:core-hq,代碼行數:50,代碼來源:utils.py


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