def createuser(): """ Create a new user """ from openspending.core import db from openspending.model import Account import sys import getpass from werkzeug.security import check_password_hash, generate_password_hash account = Account() account.fullname = raw_input("User Full name: ") account.email = raw_input("User email: ") if Account.by_email(account.email): raise CommandException("Account `%s` already exists." % account.email) pass1 = getpass.getpass("Password: "******"Password again: ") if pass1 != pass2: print "passwords do not match" sys.exit() account.password = generate_password_hash(pass1) isadmin = raw_input("User is admin (leave blank for no): ") if not isadmin: account.admin = False else: account.admin = True account.verified = True db.session.add(account) db.session.commit()
def make_account(name='test', fullname='Test User', email='*****@*****.**'): from openspending.model import Account account = Account() account.name = name account.fullname = fullname account.email = email db.session.add(account) db.session.commit() return account
def make_account(name="test", fullname="Test User", email="*****@*****.**", twitter="testuser", admin=False): from openspending.model import Account # First see if the account already exists and if so, return it account = Account.by_name(name) if account: return account # Account didn't exist so we create it and return it account = Account() account.name = name account.fullname = fullname account.email = email account.twitter_handle = twitter account.admin = admin db.session.add(account) db.session.commit() return account
def make_account(name='test', fullname='Test User', email='*****@*****.**', twitter='testuser', admin=False): from openspending.model import Account # First see if the account already exists and if so, return it account = Account.by_name(name) if account: return account # Account didn't exist so we create it and return it account = Account() account.name = name account.fullname = fullname account.email = email account.twitter_handle = twitter account.admin = admin db.session.add(account) db.session.commit() return account