class Pickup(db.Model): id = db.Column(db.Integer,primary_key=True) username = db.Column(db.String(120), nullable=False) location = db.Column(db.Text,nullable=False) trip = db.Column(db.Text,nullable=False) def __repr__(self): return f"Post('{self.username}','{self.location}','{self.trip}')"
class Terminal(db.Model): id = db.Column(db.Integer,primary_key=True) username = db.Column(db.String(120), nullable=False) trip_date = db.Column(db.Text,nullable=False) destination = db.Column(db.Text,nullable=False) user_id= db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Post('{self.title}','{self.content}')"
class User(db.Model): id = db.Column(db.Integer,primary_key=True) username = db.Column(db.String(20),unique=True, nullable=False) email = db.Column(db.String(120),unique=True, nullable=False) # image_file = db.Column(db.String(20),nullable=False, default= 'default.jpg') password = db.Column(db.String(60), nullable=False) terminal = db.relationship('Terminal', backref='author',lazy=True) def __repr__(self): # return f"User('{self.username}','{self.email}','{self.image_file}','{self.password}')" return f"User('{self.username}','{self.email}','{self.password}')"
class Song(db.Model): """The database for songs.""" __tablename__ = 'songs' id = db.Column(db.Integer, primary_key=True) song = db.Column(db.String(80), nullable=False) slot = db.Column(db.DateTime, nullable=False) file_name = db.Column(db.String(80), nullable=True) def __init__(self, song, slot, file_name=None): self.song = song self.slot = slot self.file_name = file_name
class Rpi(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), unique=True) ip = db.Column(db.String(80), unique=True) ps = db.Column(db.String(8)) rt = db.Column(db.String(64)) ta = db.Column(db.Boolean()) def __init__(self, name, ip, ps='', rt='', ta=True): self.name, self.ip = name, ip self.ps, self.rt, self.ta = ps, rt, ta def __rpr__(self): return f'<Rpi {self.name} - {self.ip}>'