本文整理汇总了Python中corehq.apps.registration.models.RegistrationRequest.get_requests_today方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationRequest.get_requests_today方法的具体用法?Python RegistrationRequest.get_requests_today怎么用?Python RegistrationRequest.get_requests_today使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.registration.models.RegistrationRequest
的用法示例。
在下文中一共展示了RegistrationRequest.get_requests_today方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_domain
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def register_domain(request, domain_type=None):
domain_type = domain_type or 'commcare'
assert domain_type in DOMAIN_TYPES
_render = partial(render_registration_view, domain_type=domain_type)
is_new = False
referer_url = request.GET.get('referer', '')
active_domains_for_user = Domain.active_for_user(request.user)
if len(active_domains_for_user) <= 0 and not request.user.is_superuser:
is_new = True
domains_for_user = Domain.active_for_user(request.user, is_active=False)
if len(domains_for_user) > 0:
vals = dict(requested_domain=domains_for_user[0])
return _render(request, 'registration/confirmation_waiting.html', {
'requested_domain': domains_for_user[0]
})
if request.method == 'POST':
nextpage = request.POST.get('next')
org = request.POST.get('org')
form = DomainRegistrationForm(request.POST)
if form.is_valid():
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
vals = {'error_msg':'Number of domains requested today exceeds limit ('+str(max_req)+') - contact Dimagi',
'show_homepage_link': 1 }
return _render(request, 'error.html', vals)
request_new_domain(
request, form, org, new_user=is_new, domain_type=domain_type)
requested_domain = form.cleaned_data['domain_name']
if is_new:
vals = dict(alert_message="An email has been sent to %s." % request.user.username, requested_domain=requested_domain)
return _render(request, 'registration/confirmation_sent.html', vals)
else:
messages.success(request, '<strong>The project {project_name} was successfully created!</strong> An email has been sent to {username} for your records.'.format(
username=request.user.username,
project_name=requested_domain
), extra_tags="html")
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[requested_domain]))
else:
if nextpage:
# messages.error(request, "The new project could not be created! Please make sure to fill out all fields of the form.")
return orgs_landing(request, org, form=form)
else:
form = DomainRegistrationForm(initial={'domain_type': domain_type})
return _render(request, 'registration/domain_request.html', {
'form': form,
'is_new': is_new,
})
示例2: post
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def post(self, request, *args, **kwargs):
referer_url = request.GET.get('referer', '')
nextpage = request.POST.get('next')
form = DomainRegistrationForm(request.POST)
context = self.get_context_data(form=form)
if not form.is_valid():
return self.render_to_response(context)
if settings.RESTRICT_DOMAIN_CREATION and not request.user.is_superuser:
context.update({
'current_page': {'page_name': _('Oops!')},
'error_msg': _('Your organization has requested that project creation be restricted. '
'For more information, please speak to your administrator.'),
})
return render(request, 'error.html', context)
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
context.update({
'current_page': {'page_name': _('Oops!')},
'error_msg': _(
'Number of projects requested today exceeds limit (%d) - contact Dimagi'
) % max_req,
'show_homepage_link': 1
})
return render(request, 'error.html', context)
try:
domain_name = request_new_domain(request, form, is_new_user=self.is_new_user)
except NameUnavailableException:
context.update({
'current_page': {'page_name': _('Oops!')},
'error_msg': _('Project name already taken - please try another'),
'show_homepage_link': 1
})
return render(request, 'error.html', context)
if self.is_new_user:
context.update({
'requested_domain': domain_name,
'current_page': {'page_name': _('Confirm Account')},
})
track_workflow(self.request.user.email, "Created new project")
return render(request, 'registration/confirmation_sent.html', context)
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[domain_name]))
示例3: post
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def post(self, request, *args, **kwargs):
referer_url = request.GET.get('referer', '')
nextpage = request.POST.get('next')
form = DomainRegistrationForm(request.POST, current_user=request.couch_user)
context = self.get_context_data(form=form)
if form.is_valid():
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
context.update({
'current_page': {'page_name': _('Oops!')},
'error_msg': _(
'Number of domains requested today exceeds limit (%d) - contact Dimagi'
) % max_req,
'show_homepage_link': 1
})
return render(request, 'error.html', context)
try:
domain_name = request_new_domain(
request, form, is_new_user=self.is_new_user)
except NameUnavailableException:
context.update({
'current_page': {'page_name': _('Oops!')},
'error_msg': _('Project name already taken - please try another'),
'show_homepage_link': 1
})
return render(request, 'error.html', context)
if self.is_new_user:
context.update({
'requested_domain': domain_name,
'track_domain_registration': True,
'current_page': {'page_name': _('Confirm Account')},
})
return render(request, 'registration/confirmation_sent.html', context)
else:
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[domain_name]))
return self.render_to_response(context)
示例4: register_domain
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def register_domain(request, domain_type=None):
domain_type = domain_type or 'commcare'
if domain_type not in DOMAIN_TYPES or request.couch_user.is_commcare_user():
raise Http404()
context = get_domain_context(domain_type)
is_new = False
referer_url = request.GET.get('referer', '')
active_domains_for_user = Domain.active_for_user(request.user)
if len(active_domains_for_user) <= 0 and not request.user.is_superuser:
is_new = True
domains_for_user = Domain.active_for_user(request.user, is_active=False)
if len(domains_for_user) > 0:
context['requested_domain'] = domains_for_user[0]
return render(request, 'registration/confirmation_waiting.html',
context)
if request.method == 'POST':
nextpage = request.POST.get('next')
org = request.POST.get('org')
form = DomainRegistrationForm(request.POST)
if form.is_valid():
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
context.update({
'error_msg': _(
'Number of domains requested today exceeds limit (%d) - contact Dimagi'
) % max_req,
'show_homepage_link': 1
})
return render(request, 'error.html', context)
request_new_domain(
request, form, org, new_user=is_new, domain_type=domain_type)
requested_domain = form.cleaned_data['domain_name']
if is_new:
context.update({
'alert_message': _("An email has been sent to %s.") % request.user.username,
'requested_domain': requested_domain
})
return render(request, 'registration/confirmation_sent.html',
context)
else:
messages.success(request, _(
'<strong>The project {project} was successfully created!</strong> '
'An email has been sent to {user} for your records.').format(
project=requested_domain, user=request.user.username),
extra_tags="html")
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[requested_domain]))
else:
if nextpage:
return orgs_landing(request, org, form=form)
else:
form = DomainRegistrationForm(initial={'domain_type': domain_type})
context.update({
'form': form,
'is_new': is_new,
})
return render(request, 'registration/domain_request.html', context)
示例5: register_domain
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def register_domain(request, domain_type=None):
domain_type = domain_type or 'commcare'
if domain_type not in DOMAIN_TYPES or (not request.couch_user) or request.couch_user.is_commcare_user():
raise Http404()
context = get_domain_context(domain_type)
is_new = False
referer_url = request.GET.get('referer', '')
active_domains_for_user = Domain.active_for_user(request.user)
if len(active_domains_for_user) <= 0 and not request.user.is_superuser:
is_new = True
domains_for_user = Domain.active_for_user(request.user, is_active=False)
if len(domains_for_user) > 0:
context['requested_domain'] = domains_for_user[0]
return render(request, 'registration/confirmation_waiting.html',
context)
if request.method == 'POST':
nextpage = request.POST.get('next')
org = request.POST.get('org')
form = DomainRegistrationForm(request.POST)
if form.is_valid():
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
context.update({
'error_msg': _(
'Number of domains requested today exceeds limit (%d) - contact Dimagi'
) % max_req,
'show_homepage_link': 1
})
return render(request, 'error.html', context)
try:
domain_name = request_new_domain(
request, form, org, new_user=is_new, domain_type=domain_type)
except NameUnavailableException:
context.update({
'error_msg': _('Project name already taken - please try another'),
'show_homepage_link': 1
})
return render(request, 'error.html', context)
if is_new:
context.update({
'alert_message': _("An email has been sent to %s.") % request.user.username,
'requested_domain': domain_name,
'track_domain_registration': True,
})
return render(request, 'registration/confirmation_sent.html',
context)
else:
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[domain_name]))
else:
if nextpage:
return orgs_landing(request, org, form=form)
else:
form = DomainRegistrationForm(initial={'domain_type': domain_type})
context.update({
'form': form,
'is_new': is_new,
})
return render(request, 'registration/domain_request.html', context)
示例6: register_domain
# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_requests_today [as 别名]
def register_domain(request, domain_type=None):
domain_type = domain_type or "commcare"
assert domain_type in DOMAIN_TYPES
context = get_domain_context(domain_type)
is_new = False
referer_url = request.GET.get("referer", "")
active_domains_for_user = Domain.active_for_user(request.user)
if len(active_domains_for_user) <= 0 and not request.user.is_superuser:
is_new = True
domains_for_user = Domain.active_for_user(request.user, is_active=False)
if len(domains_for_user) > 0:
context["requested_domain"] = domains_for_user[0]
return render(request, "registration/confirmation_waiting.html", context)
if request.method == "POST":
nextpage = request.POST.get("next")
org = request.POST.get("org")
form = DomainRegistrationForm(request.POST)
if form.is_valid():
reqs_today = RegistrationRequest.get_requests_today()
max_req = settings.DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY
if reqs_today >= max_req:
context.update(
{
"error_msg": _("Number of domains requested today exceeds limit (%d) - contact Dimagi")
% max_req,
"show_homepage_link": 1,
}
)
return render(request, "error.html", context)
request_new_domain(request, form, org, new_user=is_new, domain_type=domain_type)
requested_domain = form.cleaned_data["domain_name"]
if is_new:
context.update(
{
"alert_message": _("An email has been sent to %s.") % request.user.username,
"requested_domain": requested_domain,
}
)
return render(request, "registration/confirmation_sent.html", context)
else:
messages.success(
request,
_(
"<strong>The project {project} was successfully created!</strong> "
"An email has been sent to {user} for your records."
).format(project=requested_domain, user=request.user.username),
extra_tags="html",
)
if nextpage:
return HttpResponseRedirect(nextpage)
if referer_url:
return redirect(referer_url)
return HttpResponseRedirect(reverse("domain_homepage", args=[requested_domain]))
else:
if nextpage:
return orgs_landing(request, org, form=form)
else:
form = DomainRegistrationForm(initial={"domain_type": domain_type})
context.update({"form": form, "is_new": is_new})
return render(request, "registration/domain_request.html", context)