示例#1
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(120), unique=True)

    def __init__(self, username, password):
        self.username = username
        self.password = encodePassword(password)

    def __repr__(self):
        return '<User %r>' % self.username
示例#2
0
class Customer(db.Model):
    __tablename__ = 'customers'
    referenceNumber = db.Column(db.Integer,
                                primary_key=True,
                                autoincrement=True)
    name = db.Column(db.String, nullable=False)
    address = db.Column(db.String, nullable=False)

    bookings = db.relationship("Booking")

    def __init__(self, name, address):
        self.name = name
        self.address = address

    def __repr__(self):
        return '<Customer Name N: %r>' % self.name
示例#3
0
class Guest(db.Model):
    __tablename__ = 'guests'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String, nullable=False)
    age = db.Column(db.Integer, nullable=False)
    passportNumber = db.Column(db.String, nullable=False)

    bookingId = db.Column(db.Integer, db.ForeignKey('bookings.id'))

    def __init__(self, name, age, passportNumber, bookingId):
        self.name = name
        self.age = age
        self.passportNumber = passportNumber
        self.bookingId = bookingId

    def __repr__(self):
        return '<Guest Name N: %r>' % self.name
示例#4
0
class Extra(db.Model):
    __tablename__ = 'extras'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    type = db.Column(db.String, nullable=False)
    hireStart = db.Column(db.Date, nullable=True)
    hireEnd = db.Column(db.Date, nullable=True)

    bookingId = db.Column(db.Integer, db.ForeignKey('bookings.id'))

    def __init__(self, extraType, bookingId, hireStart=None, hireEnd=None):
        self.type = extraType
        self.hireStart = hireStart
        self.hireEnd = hireEnd
        self.bookingId = bookingId

    def __repr__(self):
        return '<Guest Name N: %r>' % self.type
示例#5
0
class Booking(db.Model):
    __tablename__ = 'bookings'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    arrivalDate = db.Column(db.Date, nullable=False)
    departureDate = db.Column(db.Date, nullable=False)

    dietaryReqs = db.Column(db.String, nullable=True)

    customerId = db.Column(db.Integer,
                           db.ForeignKey('customers.referenceNumber'))

    guests = db.relationship("Guest")
    extras = db.relationship("Extra")

    def __init__(self, arrival, departure, customerId):
        self.arrivalDate = arrival
        self.departureDate = departure
        self.customerId = customerId

    def __repr__(self):
        return '<Booking N: %r>' % self.id