class Admin(db.Model): __tablename__ = 'administrador' id = db.Column(db.Integer, autoincrement=True, primary_key=True) usuario = db.Column(db.String(100), nullable=False) senha = db.Column(db.String(100), nullable=False) @property def is_authenticated(self): return True @property def is_active(self): return True @property def is_anonymous(self): return False def get_id(self): return str(self.id) def __init__(self, usuario, senha): self.usuario = usuario self.senha = senha
class User(db.Model, UserMixin): 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), default='default.jpg') password = db.Column(db.String(60), nullable=False) Book = db.relationship('Book', backref='user', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model): __tablename__ = 'funcionarios' id = db.Column(db.Integer, autoincrement=True, primary_key=True) name = db.Column(db.String(86), nullable=False) email = db.Column(db.String(84), nullable=False, unique=True) telefone = db.Column(db.String(40), nullable=False) cod_registro = db.Column(db.String(40), nullable=False) def __init__(self, name, email, telefone, cod_registro): self.name = name self.email = email self.telefone = telefone self.cod_registro = cod_registro
class Book(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) author = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) summary = db.Column(db.Text, nullable=False) image_book = db.Column(db.String(20), nullable=False, default='book_default.jpg') user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Book('{self.title}', '{self.date_posted}')"
class User(db.Model, UserMixin): # Create a table in the db __tablename__ = 'usuario' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(70)) address = db.Column(db.String(120)) number = db.Column(db.Integer) city = db.Column(db.String(150)) state = db.Column(db.String(20)) country_code = db.Column(db.Integer) phone = db.Column(db.String(11)) email = db.Column(db.String(64), unique=True, index=True) username = db.Column(db.String(64), unique=True, index=True) password = db.Column(db.String(128)) pass_confirm = db.Column(db.String(128)) def __init__(self, name, address, number, city, state, country_code, phone, email, username, password, pass_confirm): self.name = name self.address = address self.number = number self.city = city self.state = state self.country_code = country_code self.phone = phone self.email = email self.username = username self.password = password self.pass_confirm = pass_confirm