Exemplo n.º 1
0
    def init_data(self):

        demo = User(
                name=u'demo',
                email=u'*****@*****.**',
                password=u'123456',
                role_code=USER,
                status_code=ACTIVE,
                user_detail=UserDetail(
                    sex_code=MALE,
                    age=10,
                    url=u'http://demo.example.com',
                    deposit=100.00,
                    location=u'Hangzhou',
                    bio=u'admin Guy is ... hmm ... just a demo guy.'))
        admin = User(
                name=u'admin',
                email=u'*****@*****.**',
                password=u'123456',
                role_code=ADMIN,
                status_code=ACTIVE,
                user_detail=UserDetail(
                    sex_code=MALE,
                    age=10,
                    url=u'http://admin.example.com',
                    deposit=100.00,
                    location=u'Hangzhou',
                    bio=u'admin Guy is ... hmm ... just a admin guy.'))
        db.session.add(demo)
        db.session.add(admin)
        db.session.commit()
Exemplo n.º 2
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    # Init/reset data.

    role_user = UserRole(name=u'user')
    role_admin = UserRole(name=u'admin')
    db.session.add(role_user)
    db.session.add(role_admin)
    db.session.commit()

    inactivated = UserStatus(name=u'inactivated')
    activated = UserStatus(name=u'activated')
    frozen = UserStatus(name=u'frozen')
    deleted = UserStatus(name=u'deleted')
    db.session.add(inactivated)
    db.session.add(activated)
    db.session.add(frozen)
    db.session.add(deleted)
    db.session.commit()

    demo = User(
        name=u'demo',
        email=u'*****@*****.**',
        password=u'123456',
        role=role_user,
        status=activated,
        user_detail=UserDetail(
            real_name=u'Demo Guy',
            age=10,
            url=u'http://demo.example.com',
            deposit=100.00,
            location=u'Hangzhou',
            bio=u'Demo Guy is ... hmm ... just a demo guy.',
        ),
    )
    admin = User(
        name=u'admin',
        email=u'*****@*****.**',
        password=u'123456',
        role=role_admin,
        status=activated,
        user_detail=UserDetail(
            real_name=u'admin Guy',
            age=10,
            url=u'http://admin.example.com',
            deposit=100.00,
            location=u'Hangzhou',
            bio=u'admin Guy is ... hmm ... just a admin guy.',
        ),
    )
    db.session.add(demo)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 3
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()
    # Init/reset data.

    demo = User(
        name=u'demo',
        email=u'*****@*****.**',
        password=u'123456',
        role_id=USER,
        status_id=ACTIVE,
        user_detail=UserDetail(
            age=10,
            url=u'http://demo.example.com',
            deposit=100.00,
            location=u'Hangzhou',
            bio=u'Demo Guy is ... hmm ... just a demo guy.'),
    )
    admin = User(
        name=u'admin',
        email=u'*****@*****.**',
        password=u'123456',
        role_id=ADMIN,
        status_id=ACTIVE,
        user_detail=UserDetail(
            age=10,
            url=u'http://admin.example.com',
            deposit=100.00,
            location=u'Hangzhou',
            bio=u'admin Guy is ... hmm ... just a admin guy.'),
    )
    db.session.add(demo)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 4
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    admin = User(name=u'admin',
                 email=u'*****@*****.**',
                 password=u'123456',
                 role_code=ADMIN,
                 status_code=ACTIVE,
                 user_detail=UserDetail(
                     sex_code=MALE,
                     age=10,
                     url=u'http://admin.example.com',
                     deposit=100.00,
                     location=u'Hangzhou',
                     bio=u'admin Guy is ... hmm ... just a admin guy.'))
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 5
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    admin = User(name=u'admin',
                 email=u'*****@*****.**',
                 password=u'123456',
                 role_code=ADMIN,
                 status_code=ACTIVE,
                 user_detail=UserDetail(
                     sex_code=MALE,
                     age=10,
                     url=u'http://admin.example.com',
                     deposit=100.00,
                     location=u'Hangzhou',
                     bio=u'admin Guy is ... hmm ... just a admin guy.'))

    test_user = User(name=u'test',
                     email=u'*****@*****.**',
                     password=u'123456',
                     role_code=USER,
                     status_code=ACTIVE,
                     user_detail=UserDetail(sex_code=MALE,
                                            age=29,
                                            url=u'http://test.example.com',
                                            deposit=100.00,
                                            location=u'Hangzhou',
                                            bio=u'test user guy..'))

    db.session.add(admin)
    db.session.add(test_user)
    db.session.commit()

    admin = db.session.query(User).\
        filter_by(name='admin').\
        one()

    erkki = db.session.query(User).\
        filter_by(name='test').\
        one()

    body = """
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
           """
    for i in range(1, 10):
        post = BlogPost(headline="Admin's Blog Post#{i}",
                        body=body,
                        user_id=admin.id)
        db.session.add(post)

    for i in range(1, 10):
        post = BlogPost(headline="Erkki's Blog Post #{ i }",
                        body=body,
                        user_id=erkki.id)
        db.session.add(post)

    db.session.commit()

    tag1 = Tag(tag_name='tag1', user_id=admin.id)
    tag2 = Tag(tag_name='tag2', user_id=admin.id)

    tag3 = Tag(tag_name='tag3', user_id=erkki.id)

    tag4 = Tag(tag_name='tag4', user_id=admin.id)

    db.session.add(tag1)
    db.session.add(tag2)
    db.session.add(tag3)
    db.session.add(tag4)
    db.session.commit()

    tags = [tag1, tag2]
    tags2 = [tag3]
    tags3 = [tag4]

    post1 = db.session.query(BlogPost).\
        filter_by(id=1).\
        one()

    post2 = db.session.query(BlogPost).\
        filter_by(id=10).\
        one()

    post3 = db.session.query(BlogPost).\
        filter_by(id=2).\
        one()

    post1.tags = tags
    post2.tags = tags2
    post3.tags = tags3

    db.session.add(post1)
    db.session.add(post2)
    db.session.add(post3)

    db.session.commit()