Exemplo n.º 1
0
    def update(self):
        allowed = PLOUD.registration
        if allowed:
            raise HTTPFound(location = '/signup.html')

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

        email = request.POST.get('email', '').lower()
        self.completed = request.POST.get('completed')

        if self.completed and not utils.isValidMailAddress(email):
            view.addMessage(request, 'E-Mail is required.')
            self.completed = False
            return

        exists = models.DBSession.query(
            models.WaitingList).filter_by(email=email).all()
        if email and not exists:
            exists = models.DBSession.query(
                models.User).filter_by(email=email).all()

            if not exists:
                entry = models.WaitingList(email)
                models.DBSession.add(entry)
                models.DBSession.flush()
                self.send_confirmation(email)

            if email and exists:
                view.addMessage(
                    request,
                    'The email account %s is aleady on the list.' % email)
                self.completed = False
Exemplo n.º 2
0
def addvhost(self):
    if not pol.vhosts:
        view.addMessage(
            request,
            "Virtual host is not available for your type "
            "of membership.")
        
        raise HTTPFound(location=urlmsg)

    hostname = request.str_GET['vhost'].strip().lower()
    if hostname.endswith('.%s'%PLOUD.domain):
        view.addMessage(
            request, "%s domain is not allowed."%PLOUD.domain)
        raise HTTPFound(location=urlmsg)

    conn = ploud_config.PLOUD_POOL.getconn()
    cursor = conn.cursor()

    cursor.execute(
        "SELECT host FROM vhost WHERE id = %s", (site.id,))
    sites = [row[0] for row in cursor.fetchall()]
    if sites:
        cursor.execute(
            "DELETE FROM vhost WHERE id = %s", (site.id,))
        removeVirtualHosts(sites)
            
    cursor.execute("INSERT INTO vhost(id, host) VALUES(%s, %s)",
                   (site_id, hostname))
    addVirtualHosts((hostname,), 'plone41')
    pol.changeHostsPolicy((hostname,), site_name)

    cursor.close()
    conn.commit()
    ploud_config.PLOUD_POOL.getconn(conn)
    view.addMessage(request, "Site now has new hostname.")
    raise HTTPFound(location=urlmsg)