class Members(BaseModel): Id_Member = db.Column(db.Integer, primary_key=True) Id_Person = db.Column(db.Integer, db.ForeignKey('persons.Id_Person'),nullable=False) Id_Club = db.Column(db.Integer, db.ForeignKey('clubs.Id_Club'),nullable=False) Id_Team = db.Column(db.Integer, db.ForeignKey('teams.Id_Team'),nullable=False) Date_Of = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) Nickname = db.Column(db.String(50), nullable=True) Date_To = db.Column(db.DateTime, nullable=True) Id_Position = db.Column(db.Integer, db.ForeignKey('positions.Id_Position'),nullable=False) person = db.relationship('Persons', uselist=False) position = db.relationship('Positions',uselist=False) def __repr__(self): return "'{0}'".format(self.Id_Member)
class User(BaseModel): 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) posts = db.relationship('Post',backref='author',lazy=True) def __repr__(self): return "'{0}' {1}".format(self.username,self.email)
class Teams(BaseModel): Id_Team = db.Column(db.Integer, primary_key=True) Id_Club = db.Column(db.Integer, db.ForeignKey('clubs.Id_Club'), nullable=False, unique=False) Name = db.Column(db.String(100), nullable=False) Date_Of = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) Date_To = db.Column(db.DateTime, nullable=True) members = db.relationship('Members', backref='members', lazy=True) _default_fields = [ "Id_Team", "Id_Club", "Name", "Date_Of", "Date_To", "members" ] def __repr__(self): return "'{0}'".format(self.Name)
class Clubs(BaseModel): Id_Club = db.Column(db.Integer, primary_key=True) Name = db.Column(db.String(100), nullable=False) #logo = db.Column(db.String(20),nullable=True, default='default.jpg') Logo = db.Column(db.LargeBinary(length=(2**32) - 1)) Since = db.Column(db.Integer, nullable=True) Date_Of = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) Date_To = db.Column(db.DateTime, nullable=True) teams = db.relationship('Teams', backref='teams', lazy=True) _default_fields = [ "Id_Club", "Name", "Since", "Date_Of", "Date_To", "teams" ] def __repr__(self): return "'{0}' '{1}' {2} {3}".format(self.Name, self.Since, self.Date_Of, self.Date_To)