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
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
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_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) # 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]))
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_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) # 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) url = reverse("dashboard_default", args=[requested_domain]) # If user already created an app (via prelogin demo), send them there apps = get_apps_in_domain(requested_domain.name, include_remote=False) if len(apps) == 1: app = apps[0] if len(app.modules) == 1 and len(app.modules[0].forms) == 1: url = reverse('form_source', args=[requested_domain.name, app.id, 0, 0]) return HttpResponseRedirect(url)
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]))
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)
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.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))
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))
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)