def initdb(username, password): """Initialize the database.""" click.echo("Initialize the database...") db.create_all() dj = DJ(u"Automation", u"Automation", False) db.session.add(dj) db.session.commit() cats = [ Category(u"Events", u"events", True), Category(u"Music Adds", u"music-adds", True), Category(u"Programming", u"programming", True), Category(u"Updates", u"station-updates", True), Category(u"Woove", u"woove", True) ] for cat in cats: db.session.add(cat) # Create the first account click.echo("Create {0} user...".format(username)) user = User(unicode(username), unicode(username), u"{0}@localhost".format(username)) user.set_password(unicode(password)) db.session.add(user) # The first Rotation is always the default db.session.add(Rotation(u"None")) map( db.session.add, map(Rotation, [u"Metal", u"New Music", u"Jazz", u"Rock", u"Americana"])) db.session.commit() click.echo("Database initialized.")
from wuvt.trackman.models import DJ, Rotation from wuvt.models import User db.create_all() dj = DJ(u"Automation", u"Automation", False) db.session.add(dj) db.session.commit() cats = [ Category(u"Events", u"events", True), Category(u"Music Adds", u"music-adds", True), Category(u"Programming", u"programming", True), Category(u"Updates", u"station-updates", True), Category(u"Woove", u"woove", True) ] for cat in cats: db.session.add(cat) # There must be a user called 'admin'. This is hardcoded in everything to be the superuser. user = User(u"admin", u"admin", u"*****@*****.**") user.set_password(u"Password1!") db.session.add(user) # The first Rotation is always the default db.session.add(Rotation(u"None")) map(db.session.add, map(Rotation, [u"Metal", u"New Music", u"Jazz", u"Rock", u"Americana"])) db.session.commit()
db.create_all() dj = DJ("Automation", "Automation", False) db.session.add(dj) db.session.commit() cats = [Category("News", "news", True), Category("Sports", "sports", True), Category("Weather", "weather", True), Category("Woove", "woove", True)] for cat in cats: db.session.add(cat) # There must be a user called 'admin'. This is hardcoded in everything to be the superuser. user = User("admin", "admin", "*****@*****.**") user.set_password("Password1!") db.session.add(user) # The first Rotation must be the default db.session.add(Rotation("None")); # Test data db.session.add(Track('The Divine Conspiracy', 'Epica', 'The Divine Conspiracy', 'Avalon')) db.session.add(Track('Second Stone', 'Epica', 'The Quantum Enigma', 'Nuclear Blast')) map(db.session.add, map(Rotation, ["Metal", "New Music", "Jazz", "Rock", "Americana"])) db.session.commit()