本文整理汇总了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)