Пример #1
0
    def _doadduser(self):
        user = User()
        
        user.username = c.username = request.params.getone('username')
        user.email = request.params.getone('email')
        user.role = request.params.getone('role')
        
        c.password = generate_password()
        user.password = c.password

        # Sends the email
        send_email(render('/emails/registration.mako'),
                   'Welcome to troppotardi',
                   [user.email])
        
        user.store(self.db)
        
        flash('User added successfully, an email has been sent with the password.')
        redirect(url(controller='admin', action='adduser'))
Пример #2
0
#!/usr/bin/python
from setup_config import setup_config
from couchdb import Database
from pylons import config
from troppotardi.model import Email
from troppotardi.lib.utils import send_email

if __name__ == '__main__':
    setup_config()

    # Set up the database
    db = Database(config['couchdb_uri'])
    emails = Email.by_time(db)


    for email in emails:
        send_email(body=email.text,
                   subject=email.subject,
                   recipients=email.recipients,
                   sender=email.sender)
        db.delete(email)