Exemple #1
0
 def register_new_user(self, data):
     reg_form = RegisterWebUserForm(data['data'])
     if reg_form.is_valid():
         ab_test = ab_tests.SessionAbTest(ab_tests.APPCUES_V3_APP, self.request)
         appcues_ab_test = ab_test.context['version']
         self._create_new_account(reg_form, additional_hubspot_data={
             "appcues_test": appcues_ab_test,
         })
         try:
             request_new_domain(
                 self.request, reg_form, is_new_user=True
             )
         except NameUnavailableException:
             # technically, the form should never reach this as names are
             # auto-generated now. But, just in case...
             logging.error("There as an issue generating a unique domain name "
                           "for a user during new registration.")
             return {
                 'errors': {
                     'project name unavailable': [],
                 }
             }
         return {
             'success': True,
             'appcues_ab_test': appcues_ab_test
         }
     logging.error(
         "There was an error processing a new user registration form."
         "This shouldn't happen as validation should be top-notch "
         "client-side. Here is what the errors are: {}".format(reg_form.errors))
     return {
         'errors': reg_form.errors,
     }
Exemple #2
0
 def register_new_user(self, data):
     reg_form = RegisterWebUserForm(data['data'],
                                    show_number=self.ab_show_number)
     if reg_form.is_valid():
         self._create_new_account(reg_form)
         try:
             request_new_domain(self.request, reg_form, is_new_user=True)
         except NameUnavailableException:
             # technically, the form should never reach this as names are
             # auto-generated now. But, just in case...
             logging.error(
                 "There as an issue generating a unique domain name "
                 "for a user during new registration.")
             return {
                 'errors': {
                     'project name unavailable': [],
                 }
             }
         return {
             'success': True,
         }
     logging.error(
         "There was an error processing a new user registration form."
         "This shouldn't happen as validation should be top-notch "
         "client-side. Here is what the errors are: {}".format(
             reg_form.errors))
     return {
         'errors': reg_form.errors,
     }
Exemple #3
0
 def register_new_user(self, data):
     reg_form = RegisterWebUserForm(data['data'])
     if reg_form.is_valid():
         ab_test = ab_tests.SessionAbTest(ab_tests.APPCUES_V3_APP, self.request)
         appcues_ab_test = ab_test.context['version']
         self._create_new_account(reg_form, additional_hubspot_data={
             "appcues_test": appcues_ab_test,
         })
         try:
             request_new_domain(
                 self.request, reg_form, is_new_user=True
             )
         except NameUnavailableException:
             # technically, the form should never reach this as names are
             # auto-generated now. But, just in case...
             logging.error("There as an issue generating a unique domain name "
                           "for a user during new registration.")
             return {
                 'errors': {
                     'project name unavailable': [],
                 }
             }
         return {
             'success': True,
             'appcues_ab_test': appcues_ab_test
         }
     logging.error(
         "There was an error processing a new user registration form."
         "This shouldn't happen as validation should be top-notch "
         "client-side. Here is what the errors are: {}".format(reg_form.errors))
     return {
         'errors': reg_form.errors,
     }
Exemple #4
0
    def register_new_user(self, data):
        idp = None
        if settings.ENFORCE_SSO_LOGIN:
            idp = IdentityProvider.get_required_identity_provider(
                data['data']['email'])

        reg_form = RegisterWebUserForm(data['data'], is_sso=idp is not None)
        if reg_form.is_valid():
            ab_test = ab_tests.SessionAbTest(ab_tests.APPCUES_V3_APP,
                                             self.request)
            appcues_ab_test = ab_test.context['version']

            if idp:
                signup_request = AsyncSignupRequest.create_from_registration_form(
                    reg_form,
                    additional_hubspot_data={
                        "appcues_test": appcues_ab_test,
                    })
                return {
                    'success': True,
                    'appcues_ab_test': appcues_ab_test,
                    'ssoLoginUrl': idp.get_login_url(signup_request.username),
                    'ssoIdpName': idp.name,
                }

            self._create_new_account(reg_form,
                                     additional_hubspot_data={
                                         "appcues_test": appcues_ab_test,
                                     })
            try:
                request_new_domain(self.request,
                                   reg_form.cleaned_data['project_name'],
                                   is_new_user=True)
            except NameUnavailableException:
                # technically, the form should never reach this as names are
                # auto-generated now. But, just in case...
                logging.error(
                    "There as an issue generating a unique domain name "
                    "for a user during new registration.")
                return {
                    'errors': {
                        'project name unavailable': [],
                    }
                }
            return {
                'success': True,
                'appcues_ab_test': appcues_ab_test,
            }
        logging.error(
            "There was an error processing a new user registration form."
            "This shouldn't happen as validation should be top-notch "
            "client-side. Here is what the errors are: {}".format(
                reg_form.errors))
        return {
            'errors': reg_form.errors,
        }
Exemple #5
0
    def register_new_user(self, data):
        reg_form = RegisterWebUserForm(
            data['data'],
            show_number=self.ab_show_number,
        )
        if reg_form.is_valid():
            self._create_new_account(reg_form)
            try:
                request_new_domain(self.request, reg_form, is_new_user=True)
            except NameUnavailableException:
                # technically, the form should never reach this as names are
                # auto-generated now. But, just in case...
                logging.error(
                    "There as an issue generating a unique domain name "
                    "for a user during new registration.")
                return {
                    'errors': {
                        'project name unavailable': [],
                    }
                }

            persona_fields = {}
            if reg_form.cleaned_data['persona']:
                persona_fields['buyer_persona'] = reg_form.cleaned_data[
                    'persona']
                if reg_form.cleaned_data['persona_other']:
                    persona_fields[
                        'buyer_persona_other'] = reg_form.cleaned_data[
                            'persona_other']
                couch_user = CouchUser.get_by_username(
                    reg_form.cleaned_data['email'])
                if couch_user:
                    update_hubspot_properties.delay(couch_user, persona_fields)

            return {
                'success':
                True,
                'is_mobile_experience':
                (reg_form.cleaned_data.get('is_mobile')
                 and toggles.MOBILE_SIGNUP_REDIRECT_AB_TEST.enabled(
                     reg_form.cleaned_data['email'], toggles.NAMESPACE_USER))
            }
        logging.error(
            "There was an error processing a new user registration form."
            "This shouldn't happen as validation should be top-notch "
            "client-side. Here is what the errors are: {}".format(
                reg_form.errors))
        return {
            'errors': reg_form.errors,
        }
 def register_new_user(self, data):
     reg_form = RegisterWebUserForm(
         data['data'],
         show_number=(
             self.ab.version == ab_tests.NEW_USER_NUMBER_OPTION_SHOW_NUM))
     if reg_form.is_valid():
         self._create_new_account(reg_form)
         try:
             requested_domain = request_new_domain(self.request,
                                                   reg_form,
                                                   is_new_user=True)
             # If user created a form via prelogin demo, create an app for them
             if reg_form.cleaned_data['xform']:
                 lang = 'en'
                 app = Application.new_app(requested_domain,
                                           "Untitled Application")
                 module = Module.new_module(_("Untitled Module"), lang)
                 app.add_module(module)
                 save_xform(app, app.new_form(0, "Untitled Form", lang),
                            reg_form.cleaned_data['xform'])
                 app.save()
                 web_user = WebUser.get_by_username(
                     reg_form.cleaned_data['email'])
                 if web_user:
                     update_hubspot_properties(web_user, {
                         'signup_via_demo': 'yes',
                     })
         except NameUnavailableException:
             # technically, the form should never reach this as names are
             # auto-generated now. But, just in case...
             logging.error(
                 "There as an issue generating a unique domain name "
                 "for a user during new registration.")
             return {
                 'errors': {
                     'project name unavailable': [],
                 }
             }
         return {
             'success': True,
         }
     logging.error(
         "There was an error processing a new user registration form."
         "This shouldn't happen as validation should be top-notch "
         "client-side. Here is what the errors are: {}".format(
             reg_form.errors))
     return {
         'errors': reg_form.errors,
     }
Exemple #7
0
    def register_new_user(self, data):
        reg_form = RegisterWebUserForm(
            data['data'],
            show_number=self.ab_show_number,
        )
        if reg_form.is_valid():
            self._create_new_account(reg_form)
            try:
                request_new_domain(self.request, reg_form, is_new_user=True)
            except NameUnavailableException:
                # technically, the form should never reach this as names are
                # auto-generated now. But, just in case...
                logging.error(
                    "There as an issue generating a unique domain name "
                    "for a user during new registration.")
                return {
                    'errors': {
                        'project name unavailable': [],
                    }
                }

            username = reg_form.cleaned_data['email']
            appcues_ab_test = toggles.APPCUES_AB_TEST.enabled(
                username, toggles.NAMESPACE_USER)

            return {
                'success':
                True,
                'is_mobile_experience':
                (toggles.MOBILE_SIGNUP_REDIRECT_AB_TEST_CONTROLLER.enabled(
                    username)
                 and toggles.MOBILE_SIGNUP_REDIRECT_AB_TEST.enabled(
                     username, toggles.NAMESPACE_USER)),
                'appcues_ab_test':
                appcues_ab_test,
            }
        logging.error(
            "There was an error processing a new user registration form."
            "This shouldn't happen as validation should be top-notch "
            "client-side. Here is what the errors are: {}".format(
                reg_form.errors))
        return {
            'errors': reg_form.errors,
        }
Exemple #8
0
 def register_new_user(self, data):
     reg_form = RegisterWebUserForm(data['data'])
     if reg_form.is_valid():
         self._create_new_account(reg_form)
         try:
             requested_domain = request_new_domain(
                 self.request, reg_form, is_new_user=True
             )
             # If user created a form via prelogin demo, create an app for them
             if reg_form.cleaned_data['xform']:
                 lang = 'en'
                 app = Application.new_app(requested_domain, "Untitled Application")
                 module = Module.new_module(_("Untitled Module"), lang)
                 app.add_module(module)
                 save_xform(app, app.new_form(0, "Untitled Form", lang), reg_form.cleaned_data['xform'])
                 app.save()
                 web_user = WebUser.get_by_username(reg_form.cleaned_data['email'])
                 if web_user:
                     update_hubspot_properties(web_user, {
                         'signup_via_demo': 'yes',
                     })
         except NameUnavailableException:
             # technically, the form should never reach this as names are
             # auto-generated now. But, just in case...
             logging.error("There as an issue generating a unique domain name "
                           "for a user during new registration.")
             return {
                 'errors': {
                     'project name unavailable': [],
                 }
             }
         return {
             'success': True,
         }
     logging.error(
         "There was an error processing a new user registration form."
         "This shouldn't happen as validation should be top-notch "
         "client-side. Here is what the errors are: {}".format(reg_form.errors))
     return {
         'errors': reg_form.errors,
     }