Beispiel #1
0
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()
Beispiel #2
0
def shell_account():
    account = Account.by_name(SHELL_USER)
    if account is not None:
        return account
    account = Account()
    account.name = SHELL_USER
    db.session.add(account)
    return account
Beispiel #3
0
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
Beispiel #4
0
 def test_settings(self, model_mock, update_mock):
     account = Account()
     account.name = 'mockaccount'
     db.session.add(account)
     db.session.commit()
     model_mock.return_value = account
     update_mock.return_value = True
     response = self.app.get(url(controller='account', action='settings'),
                             extra_environ={'REMOTE_USER': '******'})
Beispiel #5
0
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