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'))
def setup_app(command, conf, vars): """Place any commands to setup troppotardi here""" config = load_environment(conf.global_conf, conf.local_conf) print "Syncing the couchdb database..." db = Database(config['couchdb_uri']) ViewDefinition.sync_many(db, [ Image.pending_by_time, Image.by_day, Image.deleted_by_time, User.by_time, User.by_username, Email.by_time, ]) if not list(User.by_username(db)): print "Creating first user - username and password \"admin\"" admin = User() admin.username = "******" admin.password = "******" admin.email = "*****@*****.**" admin.role = "Admin" admin.store(db, revised_by=False) print "Done."