Esempio n. 1
0
    def update(self):
        allowed = PLOUD.registration
        if not allowed:
            raise HTTPFound(location = '/waitinglist.html')

        principal = authenticated_userid(self.request)
        if principal:
            raise HTTPFound(location = '/dashboard.html')

        errors, data = validate_signup(self.request)
        if errors:
            return

        email = data['signup-email']
        site_name = data['signup-site-name']
        password = ''.join(
            random.choice(ALLOWED_SITE_NAME_CHARS) for i in range(8))

        user = User(email, password, 98)
        token = user.token
        Session.add(user)
        Session.flush()

        uri = user.uri

        send_activation(email, token)

        try:
            utils.provision_site(user, 'plone41', site_name)
        except Exception, exc:
            transaction.abort()
            self.errors = {'signup-site-name': str(exc)}
            log.exception('Site provision problem')
            return
Esempio n. 2
0
    def send_confirmation(self, email):
        template = renderers.get_renderer('newui/waitinglist_email.txt').implementation()
        data = dict(host=EMAIL_HOST, email=email)
        msg = MIMEText(str(template(**data)))
        msg['Subject'] = 'Ploud waiting list'
        msg['From'] = EMAIL_FROM
        msg['To'] = email

        try:
            server = smtplib.SMTP(MTA)
            server.sendmail(EMAIL_FROM, [email], msg.as_string())
            server.quit()
        except Exception, e:
            log.exception(str(e))
            print msg.as_string()
Esempio n. 3
0
def SignupView(request):
    PLOUD = ptah.get_settings('ploud', request.registry)
    allowed = PLOUD['registration']
    if not allowed:
        return HTTPFound(location = '/waitinglist.html')

    principal = authenticated_userid(request)
    if principal:
        return HTTPFound(location = '/dashboard.html')

    errors, data = validate_signup(request)
    if errors:
        return HTTPFound(location='/index.html')

    email = data['signup-email']
    site_name = data['signup-site-name']
    site_language = data['signup-site-language']
    password = ''.join(
        random.choice(ALLOWED_SITE_NAME_CHARS) for i in range(8))

    user = User(email, ptah.pwd_tool.encode(password), 98)
    token = user.token
    Session = ptah.get_session()
    Session.add(user)
    Session.flush()

    uri = user.__uri__

    FE = ptah.get_settings('frontend', request.registry)

    if FE['validation']:
        send_activation(email, token)
    else:
        user.type = 0
        user.token = None
        user.validated = datetime.datetime.now()

    try:
        utils.provision_site(user, 'plone41', site_name, language=site_language)
    except Exception, exc:
        transaction.abort()
        errors = {'signup-site-name': str(exc)}
        log.exception('Site provision problem')
        return HTTPFound(location='/index.html')