-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmanage.py
More file actions
38 lines (26 loc) · 769 Bytes
/
manage.py
File metadata and controls
38 lines (26 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python2
from flask.cli import FlaskGroup
import click
import os
os.environ['FLASK_APP'] = 'asmlearner/__init__.py'
@click.group(cls=FlaskGroup)
@click.pass_context
def cli(ctx):
pass
@cli.command()
def admin():
'''Creates an editor account from the console.'''
from asmlearner.db.models import User
import getpass
id_ = raw_input('ID: ')
password_ = getpass.getpass('PW: ')
user = User.create(name=id_, password=password_, role='admin').save(True)
print 'Created user %r with id %r' % (user.name, user.id)
@cli.command()
def initdb():
'''Creates some tables for the database'''
from asmlearner import create_db
create_db()
print 'Initialized the database.'
if __name__ == '__main__':
cli()