예제 #1
0
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)

    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap('%s#dashboard'% config_uri)
    settings = env.get('registry').settings
    engine = engine_from_config(settings, 'sa.dashboard.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all()

    def generate_password():
        return base64.urlsafe_b64encode(os.urandom(30))

    with transaction.manager:
        session = DBSession()
        users = [
            add_user(session, u'*****@*****.**', fullname='Administrator', password='******'),
        ]

        role_admin = add_role(session, 'administrator')
        role_admin.users.append(users[0])

        add_role(session, 'external_developer')
        add_role(session, 'internal_developer')
        add_role(session, 'secretary')
        add_role(session, 'customer')
        add_role(session, 'project_manager')

        session.add(GlobalConfig(id=1))
예제 #2
0
def main(argv=sys.argv):
    if len(argv) > 3:
        usage(argv)
    if len(argv) == 3:
        use_small = True
    else:
        use_small = False
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap('%s#dashboard'% config_uri)
    settings = env.get('registry').settings
    engine = engine_from_config(settings, 'sa.dashboard.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all()


    with transaction.manager:
        random.seed(42)
        session = DBSession()
        session.add(GlobalConfig(id=1))

        users = [
                 add_user(session, u'*****@*****.**', fullname='John Smith'),
                 add_user(session, u'*****@*****.**', fullname='Mr. Customer'),
        ]

        role_admin = add_role(session, 'administrator')
        role_admin.users.append(users[0])

        add_role(session, 'external_developer')
        add_role(session, 'internal_developer')
        add_role(session, 'secretary')
        role_customer = add_role(session, 'customer')
        role_customer.users.append(users[1])
        add_role(session, 'project_manager')

        if use_small:
            small_dummies(session,users,settings)
        else:
            full_dummies(session,users,settings)