def clear_db():
    session = db_session()

    session.query(Reservation).delete()
    session.query(MovieSchedule).delete()

    session.query(User).delete()
    session.query(Movie).delete()

    session.commit()
示例#2
0
def default_movie():
    movie = Movie(name="DefaultMovie",
                  picture="DefaultMovie.png",
                  info="Default info.",
                  actors="Default actors",
                  duration="2:00:00")
    session = db_session()
    session.add(movie)
    session.commit()

    return movie
示例#3
0
def default_user():
    user = User(username="******",
                firstname="DefaultUser",
                lastname="DefaultUser",
                email="*****@*****.**",
                password_hash=User.hash_password("user"),
                phone_number=".!.",
                photo="user.png",
                role='user')

    user.password = '******'
    user.credentials = b64encode(b'DefaultUser:user')
    user.wrong_credentials = b64encode(b'DefaultUser:user1')
    user.headers = {"Authorization": "Basic {}".format(user.credentials)}
    user.wrong_credentials_headers = {
        "Authorization": "Basic {}".format(user.wrong_credentials)
    }

    session = db_session()
    session.add(user)
    session.commit()

    return user
示例#4
0
def admin():
    admin = User(username="******",
                 firstname="admin",
                 lastname="admin",
                 email="*****@*****.**",
                 password_hash=User.hash_password("admin"),
                 phone_number=".!.",
                 photo="photo.jpeg",
                 role='admin')

    admin.password = '******'
    admin.credentials = b64encode(b'admin:admin')
    admin.wrong_credentials = b64encode(b'admin:admin1')
    admin.headers = {"Authorization": "Basic {}".format(admin.credentials)}
    admin.wrong_credentials_headers = {
        "Authorization": "Basic {}".format(admin.wrong_credentials)
    }

    session = db_session()
    session.add(admin)
    session.commit()

    return admin
示例#5
0
def session():
    session = db_session()
    return session
示例#6
0
from movie_app.models import User, Movie, MovieSchedule, Reservation
from movie_app import db_session
# TODO : rewrite and test
session = db_session()

data = \
[
    [
        User(id=1, username="******",    firstname="Ivan",   lastname="Manchur",   email="*****@*****.**",    password_hash=User.hash_password("lavuna2002"),    phone_number="90123123",   photo="photo.jpeg"),
        User(id=2, username="******",   firstname="Borys",  lastname="Laplas",    email="*****@*****.**",     password_hash=User.hash_password("laplap2002"),    phone_number="901231233",  photo="photo.jpeg"),
        User(id=3, username="******",      firstname="Ostap",  lastname="Manchur",   email="*****@*****.**",  password_hash=User.hash_password("ostap19991999"), phone_number="517294381",  photo="photo.jpeg"),
        User(id=4, username="******",     firstname="Julian", lastname="*********", email="*****@*****.**",     password_hash=User.hash_password("qwerty123"),     phone_number="872368923",  photo="photo.jpeg"),
        User(id=5, username="******",  firstname="Adrian", lastname="Bilder",    email="*****@*****.**", password_hash=User.hash_password("all123"),        phone_number="90121233123",photo="photo.jpeg")
    ],
    [
        MovieSchedule(id=1,  movie_id=1,  date="1999-03-14", time="12:53:42"),
        MovieSchedule(id=2,  movie_id=1,  date="1999-03-14", time="15:19:32"),
        MovieSchedule(id=3,  movie_id=1,  date="1999-03-14", time="18:54:49"),
        MovieSchedule(id=4,  movie_id=1,  date="1999-04-14", time="12:53:42"),
        MovieSchedule(id=5,  movie_id=1,  date="1999-04-14", time="15:19:32"),
        MovieSchedule(id=6,  movie_id=1,  date="1999-04-14", time="18:54:49"),
        MovieSchedule(id=7,  movie_id=1,  date="1999-05-14", time="12:53:42"),
        MovieSchedule(id=8,  movie_id=1,  date="1999-05-14", time="15:19:32"),
        MovieSchedule(id=9,  movie_id=1,  date="1999-05-14", time="18:54:49"),
        MovieSchedule(id=10, movie_id=2,  date="1999-03-14", time="10:53:42"),
        MovieSchedule(id=11, movie_id=2,  date="1999-03-14", time="13:19:32"),
        MovieSchedule(id=12, movie_id=2,  date="1999-03-14", time="21:54:49"),
        MovieSchedule(id=13, movie_id=2,  date="1999-04-14", time="10:53:42"),
        MovieSchedule(id=14, movie_id=2,  date="1999-04-14", time="13:19:32"),
        MovieSchedule(id=15, movie_id=2,  date="1999-04-14", time="21:54:49"),
        MovieSchedule(id=16, movie_id=2,  date="1999-05-14", time="10:53:42"),