当前位置: 首页>>代码示例>>Python>>正文


Python RegistrationRequest.get_by_guid方法代码示例

本文整理汇总了Python中corehq.apps.registration.models.RegistrationRequest.get_by_guid方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationRequest.get_by_guid方法的具体用法?Python RegistrationRequest.get_by_guid怎么用?Python RegistrationRequest.get_by_guid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.apps.registration.models.RegistrationRequest的用法示例。


在下文中一共展示了RegistrationRequest.get_by_guid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_by_guid [as 别名]
    def handle(self, *args, **options):
        django_requests = OldRegistrationRequest.objects.all()

        print "Migrating RegistrationRequest Model from django to couch"

        for request in django_requests:
            existing_request = None
            try:
                existing_request = RegistrationRequest.get_by_guid(request.activation_guid)
            except Exception:
                pass
            try:
                if not existing_request:
                    new_req = RegistrationRequest(tos_confirmed=request.tos_confirmed,
                        request_time=request.request_time,
                        request_ip=request.request_ip,
                        activation_guid=request.activation_guid,
                        confirm_time=request.confirm_time,
                        confirm_ip=request.confirm_ip,
                        domain=request.domain.name,
                        new_user_username=request.new_user.username,
                        requesting_user_username=request.requesting_user.username)
                    new_req.save()
            except Exception as e:
                print "There was an error migrating a registration request with guid %s." % request.activation_guid
                print "Error: %s" % e
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:28,代码来源:migrate_registration_request_to_couch.py

示例2: confirm_domain

# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_by_guid [as 别名]
def confirm_domain(request, guid=None):
    error = None
    # Did we get a guid?
    if guid is None:
        error = _('An account activation key was not provided.  If you think this '
                  'is an error, please contact the system administrator.')

    # Does guid exist in the system?
    else:
        req = RegistrationRequest.get_by_guid(guid)
        if not req:
            error = _('The account activation key "%s" provided is invalid. If you '
                      'think this is an error, please contact the system '
                      'administrator.') % guid

    if error is not None:
        context = {
            'message_title': _('Account not activated'),
            'message_subtitle': _('Email not yet confirmed'),
            'message_body': error,
        }
        return render(request, 'registration/confirmation_error.html', context)

    requested_domain = Domain.get_by_name(req.domain)

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert(req.confirm_time is not None and req.confirm_ip is not None)
        messages.success(request, 'Your account %s has already been activated. '
            'No further validation is required.' % req.new_user_username)
        return HttpResponseRedirect(reverse("dashboard_default", args=[requested_domain]))

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    messages.success(request,
            'Your account has been successfully activated.  Thank you for taking '
            'the time to confirm your email address: %s.'
        % (requesting_user.username))
    track_workflow(requesting_user.email, "Confirmed new project")
    track_confirmed_account_on_hubspot.delay(requesting_user)
    return HttpResponseRedirect(reverse("dashboard_default", args=[requested_domain]))
开发者ID:johan--,项目名称:commcare-hq,代码行数:51,代码来源:views.py

示例3: confirm_domain

# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_by_guid [as 别名]
def confirm_domain(request, guid=None):
    # Did we get a guid?
    vals = {}
    if guid is None:
        vals['message_title'] = 'Missing Activation Key'
        vals['message_subtitle'] = 'Account Activation Failed'
        vals['message_body'] = 'An account activation key was not provided. If you think this is an error, please contact the system administrator.'
        vals['is_error'] = True
        return render(request, 'registration/confirmation_complete.html', vals)

    # Does guid exist in the system?
    req = RegistrationRequest.get_by_guid(guid)
    if not req:
        vals['message_title'] = 'Invalid Activation Key'
        vals['message_subtitle'] = 'Account Activation Failed'
        vals['message_body'] = 'The account activation key "%s" provided is invalid. If you think this is an error, please contact the system administrator.'  % guid
        vals['is_error'] = True
        return render(request, 'registration/confirmation_complete.html', vals)

    # Has guid already been confirmed?
    vals['requested_domain'] = req.domain
    requested_domain = Domain.get_by_name(req.domain)
    
    _render = partial(
        render_registration_view, 
        domain_type='commtrack' if requested_domain.commtrack_enabled else None)

    if requested_domain.is_active:
        assert(req.confirm_time is not None and req.confirm_ip is not None)
        vals['message_title'] = 'Already Activated'
        vals['message_body'] = 'Your account %s has already been activated. No further validation is required.' % req.new_user_username
        vals['is_error'] = False
        return _render(request, 'registration/confirmation_complete.html', vals)

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_domain_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    vals['message_title'] = 'Account Confirmed'
    vals['message_subtitle'] = 'Thank you for activating your account, %s!' % requesting_user.first_name
    vals['message_body'] = 'Your account has been successfully activated. Thank you for taking the time to confirm your email address: %s.' % requesting_user.username
    vals['is_error'] = False
    return _render(request, 'registration/confirmation_complete.html', vals)
开发者ID:nikhilvarma22,项目名称:commcare-hq,代码行数:51,代码来源:views.py

示例4: confirm_domain

# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_by_guid [as 别名]
def confirm_domain(request, guid=''):
    with CriticalSection(['confirm_domain_' + guid]):
        error = None
        # Did we get a guid?
        if not guid:
            error = _('An account activation key was not provided.  If you think this '
                      'is an error, please contact the system administrator.')

        # Does guid exist in the system?
        else:
            req = RegistrationRequest.get_by_guid(guid)
            if not req:
                error = _('The account activation key "%s" provided is invalid. If you '
                          'think this is an error, please contact the system '
                          'administrator.') % guid

        if error is not None:
            context = {
                'message_body': error,
                'current_page': {'page_name': 'Account Not Activated'},
            }
            return render(request, 'registration/confirmation_error.html', context)

        requested_domain = Domain.get_by_name(req.domain)
        view_name = "dashboard_default"
        view_args = [requested_domain.name]
        if not domain_has_apps(req.domain):
            if False and settings.IS_SAAS_ENVIRONMENT and domain_is_on_trial(req.domain):
                view_name = "app_from_template"
                view_args.append("appcues")
            else:
                view_name = "default_new_app"

        # Has guid already been confirmed?
        if requested_domain.is_active:
            assert(req.confirm_time is not None and req.confirm_ip is not None)
            messages.success(request, 'Your account %s has already been activated. '
                'No further validation is required.' % req.new_user_username)
            return HttpResponseRedirect(reverse(view_name, args=view_args))

        # Set confirm time and IP; activate domain and new user who is in the
        req.confirm_time = datetime.utcnow()
        req.confirm_ip = get_ip(request)
        req.save()
        requested_domain.is_active = True
        requested_domain.save()
        requesting_user = WebUser.get_by_username(req.new_user_username)

        send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

        messages.success(request,
                'Your account has been successfully activated.  Thank you for taking '
                'the time to confirm your email address: %s.'
            % (requesting_user.username))
        track_workflow(requesting_user.email, "Confirmed new project")
        track_confirmed_account_on_hubspot_v2.delay(requesting_user)
        request.session['CONFIRM'] = True

        if settings.IS_SAAS_ENVIRONMENT:
            # For AppCues v3, land new user in Web Apps
            view_name = get_cloudcare_urlname(requested_domain.name)
        return HttpResponseRedirect(reverse(view_name, args=view_args))
开发者ID:dimagi,项目名称:commcare-hq,代码行数:64,代码来源:views.py

示例5: confirm_domain

# 需要导入模块: from corehq.apps.registration.models import RegistrationRequest [as 别名]
# 或者: from corehq.apps.registration.models.RegistrationRequest import get_by_guid [as 别名]
def confirm_domain(request, guid=None):
    # Did we get a guid?
    vals = {}
    if guid is None:
        vals["message_title"] = _("Missing Activation Key")
        vals["message_subtitle"] = _("Account Activation Failed")
        vals["message_body"] = _(
            "An account activation key was not provided.  If you think this "
            "is an error, please contact the system administrator."
        )
        vals["is_error"] = True
        return render(request, "registration/confirmation_complete.html", vals)

    # Does guid exist in the system?
    req = RegistrationRequest.get_by_guid(guid)
    if not req:
        vals["message_title"] = _("Invalid Activation Key")
        vals["message_subtitle"] = _("Account Activation Failed")
        vals["message_body"] = (
            _(
                'The account activation key "%s" provided is invalid. If you '
                "think this is an error, please contact the system "
                "administrator."
            )
            % guid
        )
        vals["is_error"] = True
        return render(request, "registration/confirmation_complete.html", vals)

    requested_domain = Domain.get_by_name(req.domain)
    context = get_domain_context(requested_domain.domain_type)
    context["requested_domain"] = req.domain

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert req.confirm_time is not None and req.confirm_ip is not None
        context["message_title"] = _("Already Activated")
        context["message_body"] = (
            _("Your account %s has already been activated. No further " "validation is required.")
            % req.new_user_username
        )
        context["is_error"] = False
        return render(request, "registration/confirmation_complete.html", context)

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    context["message_title"] = _("Account Confirmed")
    context["message_subtitle"] = _("Thank you for activating your account, %s!") % requesting_user.first_name
    context["message_body"] = (
        _(
            "Your account has been successfully activated.  Thank you for taking "
            "the time to confirm your email address: %s."
        )
        % requesting_user.username
    )
    context["is_error"] = False
    return render(request, "registration/confirmation_complete.html", context)
开发者ID:kennknowles,项目名称:commcare-hq,代码行数:67,代码来源:views.py


注:本文中的corehq.apps.registration.models.RegistrationRequest.get_by_guid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。