コード例 #1
0
class ShowTime(db):
    id = db.fields(db.serial(), db.primary(), db.unique())
    date_created = db.fields(db.datetime(auto_add=True))

    show_datetime = db.fields(db.datetime(), db.not_null())
    movie_id = db.fields(
        db.integer(),
        db.not_null(),
        db.foreignkey("movie.id", on_delete_cascade=True),
    )
    price = db.fields(db.numeric(), db.not_null())
    cinema_hall = db.fields(
        db.integer(), db.foreignkey("cinemahall.id", on_delete_cascade=True))

    class _Meta_:
        unique_together = ("show_datetime", "movie_id")

    def insert_query(self, records):
        query = super().insert_query(records)
        return get_cte_query("showtime_insert").format(query)

    def clean(self, query):
        return get_cte_query("clean_showtime").format(**query)

    def update(self, id, operator, **kwargs):
        query = super().update(id, operator, **kwargs)
        return get_cte_query("showtime_insert").format(query)
コード例 #2
0
ファイル: tickets.py プロジェクト: vadotey/movie-bookings
class Ticket(db):
    id = db.fields(db.serial(), db.primary(), db.unique())
    date_created = db.fields(db.datetime(auto_add=True))

    payment_method = db.fields(db.string(10), db.not_null())
    user_id = db.fields(db.integer(), db.not_null(),
                        db.foreignkey('users.id', on_delete_cascade=True))
    showtime_id = db.fields(db.integer(), db.not_null(), db.foreignkey(
        'showtime.id', on_delete_cascade=True))
    seat_id = db.fields(db.integer(), db.foreignkey(
        'seat.id', on_delete_cascade=True))

    class _Meta_:
        unique_together = ('showtime_id', 'seat_id')
コード例 #3
0
class Seat(db):
    id = db.fields(db.serial(), db.primary(), db.unique())
    name = db.fields(db.string(100), db.not_null())
    number = db.fields(db.integer(), db.not_null())
    date_created = db.fields(db.datetime(auto_add=True))
    cinema_hall = db.fields(
        db.integer(), db.foreignkey("cinemahall.id", on_delete_cascade=True))

    class _Meta_:
        unique_together = ("name", "cinema_hall", "number")