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


Python RegistrationRequest.get_request_for_username方法代碼示例

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


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

示例1: resend_confirmation

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_request_for_username [as 別名]
def resend_confirmation(request):
    dom_req = None
    try:
        dom_req = RegistrationRequest.get_request_for_username(request.user.username)
    except Exception:
        pass


    if not dom_req:
        inactive_domains_for_user = Domain.active_for_user(request.user, is_active=False)
        if len(inactive_domains_for_user) > 0:
            for domain in inactive_domains_for_user:
                domain.is_active = True
                domain.save()
        return redirect('domain_select')

    if request.method == 'POST': # If the form has been submitted...
        try:
            send_domain_registration_email(dom_req.new_user_username, dom_req.domain, dom_req.activation_guid)
        except Exception:
            vals = {'error_msg':'There was a problem with your request',
                    'error_details':sys.exc_info(),
                    'show_homepage_link': 1 }
            return render_to_response(request, 'error.html', vals)
        else:
            vals = dict(alert_message="An email has been sent to %s." % dom_req.new_user_username, requested_domain=dom_req.domain)
            return render_to_response(request, 'registration/confirmation_sent.html', vals)

    vals = dict(requested_domain=dom_req.domain)
    return render_to_response(request, 'registration/confirmation_resend.html', vals)
開發者ID:mchampanis,項目名稱:core-hq,代碼行數:32,代碼來源:views.py

示例2: resend_confirmation

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_request_for_username [as 別名]
def resend_confirmation(request):
    try:
        dom_req = RegistrationRequest.get_request_for_username(request.user.username)
    except Exception:
        dom_req = None
        
    if not dom_req:
        inactive_domains_for_user = Domain.active_for_user(request.user, is_active=False)
        if len(inactive_domains_for_user) > 0:
            for domain in inactive_domains_for_user:
                domain.is_active = True
                domain.save()
        return redirect('domain_select')

    _render = partial(
        render_registration_view, 
        domain_type='commtrack' if dom_req.project.commtrack_enabled else None)

    if request.method == 'POST':
        try:
            send_domain_registration_email(dom_req.new_user_username, dom_req.domain, dom_req.activation_guid)
        except Exception:
            vals = {'error_msg':'There was a problem with your request',
                    'error_details':sys.exc_info(),
                    'show_homepage_link': 1 }
            return _render(request, 'error.html', vals)
        else:
            vals = dict(alert_message="An email has been sent to %s." % dom_req.new_user_username, requested_domain=dom_req.domain)
            return _render(request, 'registration/confirmation_sent.html', vals)

    return _render(request, 'registration/confirmation_resend.html', {
        'requested_domain': dom_req.domain
    })
開發者ID:nikhilvarma22,項目名稱:commcare-hq,代碼行數:35,代碼來源:views.py

示例3: resend_confirmation

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_request_for_username [as 別名]
def resend_confirmation(request):
    try:
        dom_req = RegistrationRequest.get_request_for_username(request.user.username)
    except Exception:
        dom_req = None

    if not dom_req:
        inactive_domains_for_user = Domain.active_for_user(request.user, is_active=False)
        if len(inactive_domains_for_user) > 0:
            for domain in inactive_domains_for_user:
                domain.is_active = True
                domain.save()
        return redirect('domain_select')

    context = get_domain_context()

    if request.method == 'POST':
        try:
            send_domain_registration_email(dom_req.new_user_username,
                    dom_req.domain, dom_req.activation_guid,
                    request.user.get_full_name(), request.user.first_name)
        except Exception:
            context.update({
                'current_page': {'page_name': _('Oops!')},
                'error_msg': _('There was a problem with your request'),
                'error_details': sys.exc_info(),
                'show_homepage_link': 1,
            })
            return render(request, 'error.html', context)
        else:
            context.update({
                'requested_domain': dom_req.domain,
                'current_page': {'page_name': ('Confirmation Email Sent')},
            })
            return render(request, 'registration/confirmation_sent.html',
                context)

    context.update({
        'requested_domain': dom_req.domain,
        'current_page': {'page_name': _('Resend Confirmation Email')},
    })
    return render(request, 'registration/confirmation_resend.html', context)
開發者ID:dimagi,項目名稱:commcare-hq,代碼行數:44,代碼來源:views.py

示例4: resend_confirmation

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_request_for_username [as 別名]
def resend_confirmation(request):
    try:
        dom_req = RegistrationRequest.get_request_for_username(request.user.username)
    except Exception:
        dom_req = None
        
    if not dom_req:
        inactive_domains_for_user = Domain.active_for_user(request.user, is_active=False)
        if len(inactive_domains_for_user) > 0:
            for domain in inactive_domains_for_user:
                domain.is_active = True
                domain.save()
        return redirect('domain_select')

    context = get_domain_context(dom_req.project.domain_type)

    if request.method == 'POST':
        try:
            send_domain_registration_email(dom_req.new_user_username,
                    dom_req.domain, dom_req.activation_guid,
                    request.user.get_full_name())
        except Exception:
            context.update({
                'error_msg': _('There was a problem with your request'),
                'error_details': sys.exc_info(),
                'show_homepage_link': 1,
            })
            return render(request, 'error.html', context)
        else:
            context.update({
                'alert_message': _(
                    "An email has been sent to %s.") % dom_req.new_user_username,
                'requested_domain': dom_req.domain
            })
            return render(request, 'registration/confirmation_sent.html',
                context)

    context.update({
        'requested_domain': dom_req.domain
    })
    return render(request, 'registration/confirmation_resend.html', context)
開發者ID:johan--,項目名稱:commcare-hq,代碼行數:43,代碼來源:views.py

示例5: resend_confirmation

# 需要導入模塊: from corehq.apps.registration.models import RegistrationRequest [as 別名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_request_for_username [as 別名]
def resend_confirmation(request):
    try:
        dom_req = RegistrationRequest.get_request_for_username(request.user.username)
    except Exception:
        dom_req = None

    if not dom_req:
        inactive_domains_for_user = Domain.active_for_user(request.user, is_active=False)
        if len(inactive_domains_for_user) > 0:
            for domain in inactive_domains_for_user:
                domain.is_active = True
                domain.save()
        return redirect("domain_select")

    context = get_domain_context(dom_req.project.domain_type)

    if request.method == "POST":
        try:
            send_domain_registration_email(dom_req.new_user_username, dom_req.domain, dom_req.activation_guid)
        except Exception:
            context.update(
                {
                    "error_msg": _("There was a problem with your request"),
                    "error_details": sys.exc_info(),
                    "show_homepage_link": 1,
                }
            )
            return render(request, "error.html", context)
        else:
            context.update(
                {
                    "alert_message": _("An email has been sent to %s.") % dom_req.new_user_username,
                    "requested_domain": dom_req.domain,
                }
            )
            return render(request, "registration/confirmation_sent.html", context)

    context.update({"requested_domain": dom_req.domain})
    return render(request, "registration/confirmation_resend.html", context)
開發者ID:kennknowles,項目名稱:commcare-hq,代碼行數:41,代碼來源:views.py


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