22 lines
648 B
Python
22 lines
648 B
Python
from flask_script import Manager
|
|
from auth.models import User
|
|
from flaskbase.extensions import db
|
|
import datetime
|
|
|
|
|
|
manager = Manager()
|
|
|
|
|
|
@manager.option('-e', '--email', help='User email', default='root')
|
|
@manager.option('-p', '--password', help='Password', default='t00r')
|
|
def create_superuser(email, password):
|
|
try:
|
|
u = User(email=email, password=password, active=True,
|
|
is_superuser=True, confirmed_at=datetime.datetime.utcnow())
|
|
db.session.add(u)
|
|
db.session.commit()
|
|
|
|
print('User %s successfuly created.' % (email,))
|
|
except Exception, e:
|
|
print('User creation failed: %s' % (e,))
|