コード例 #1
0
ファイル: manage.py プロジェクト: shawnjots/eventcity
def initialize_db(credentials):
    with app.app_context():
        populate_data = True
        inspector = reflection.Inspector.from_engine(db.engine)
        table_name = 'events'
        table_names = inspector.get_table_names()
        print("[LOG] Existing tables:")
        print("[LOG] " + ','.join(table_names))
        if table_name not in table_names:
            print("[LOG] Table not found. Attempting creation")
            try:
                db.create_all()
                stamp()
            except Exception:
                populate_data = False
                print(
                    "[LOG] Could not create tables. Either database does not exist or tables already created"
                )
            if populate_data:
                credentials = credentials.split(":")
                admin_email = os.environ.get('SUPER_ADMIN_EMAIL',
                                             credentials[0])
                admin_password = os.environ.get('SUPER_ADMIN_PASSWORD',
                                                credentials[1])
                create_super_admin(admin_email, admin_password)
                populate()
        else:
            print(
                "[LOG] Tables already exist. Skipping data population & creation."
            )
コード例 #2
0
def initialize_db(credentials):
    with app.app_context():
        populate_data = True
        inspector = reflection.Inspector.from_engine(db.engine)
        table_name = 'events'
        table_names = inspector.get_table_names()
        print("[LOG] Existing tables:")
        print("[LOG] " + ','.join(table_names))
        if table_name not in table_names:
            print("[LOG] Table not found. Attempting creation")
            try:
                db.create_all()
                stamp()
            except Exception:
                populate_data = False
                print("[LOG] Could not create tables. Either database does not exist or tables already created")
            if populate_data:
                credentials = credentials.split(":")
                create_super_admin(credentials[0], credentials[1])
                populate()
        else:
            print("[LOG] Tables already exist. Skipping data population & creation.")
コード例 #3
0
def create_default_user(email, password):
    print("Your login is 'super_admin'.")
    if not email:
        ask_email = True
        while ask_email:
            email = input("Enter email for super_admin: ")
            if not re.match(r'[^@]+@[^@]+\.[^@]+', email):
                print('\nInvalid email address\n')
                continue
            ask_email = False
    if not password:
        ask_password = True
        while ask_password:
            password = getpass.getpass("Enter password for super_admin: ")
            if len(password) < 8:
                print('\nPassword should have minimum 8 characters')
                continue
            repassword = getpass.getpass("Enter your password again to confirm: ")
            if password != repassword:
                print('\nPassword did not match')
                continue
            ask_password = False
    create_super_admin(email, password)
コード例 #4
0
def create_default_user(email, password):
    print("Your login is 'super_admin'.")
    if not email:
        ask_email = True
        while ask_email:
            email = input("Enter email for super_admin    : ")
            if not re.match(r'[^@]+@[^@]+\.[^@]+', email):
                print('\nInvalid email address\n')
                continue
            ask_email = False
    if not password:
        ask_password = True
        while ask_password:
            password = getpass.getpass("Enter password for super_admin : ")
            if len(password) < 4:
                print('\nPassword should have minimum 4 characters')
                continue
            repassword = getpass.getpass("Enter your password again to confirm : ")
            if password != repassword:
                print('\nPassword did not match')
                continue
            ask_password = False
    create_super_admin(email, password)
コード例 #5
0
ファイル: utils.py プロジェクト: vivmost/open-event-server
def get_or_create_super_admin():
    user = User.query.filter_by(email="*****@*****.**").first()
    if not user:
        user = create_super_admin("*****@*****.**",
                                  "test_super_admin")
    return user
コード例 #6
0
def get_or_create_super_admin():
    user = User.query.filter_by(email="*****@*****.**").first()
    if not user:
        user = create_super_admin("*****@*****.**", "test_super_admin")
    return user