from datetime import datetime
from application import db


# db classes
class Plate(db.Model):
    __abstract__ = True
    id = db.Column(db.Integer, primary_key=True)
    plate = db.Column(db.String(40), unique=True, nullable=False)


class LoggedItem(Plate):
    __tablename__ = "LoggedItems"
    dateLogged = db.Column(db.DateTime, nullable=False)
    allowed = db.Column(db.Boolean, nullable=False, server_default=db.false())

    def __init__(
        self,
        plate: str,
        datetime: datetime,
        allowed: bool = False,
    ):
        self.plate = plate
        self.allowed = allowed
        self.dateLogged = datetime


class AllowedPlate(Plate):
    __tablename__ = "AllowedPlates"

    def __init__(self, plate: str):
        self.plate = plate
