Exemplo n.º 1
0
class UserSession(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    session_id = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f"UserSession('{self.user_id}', '{self.session_id}')"
Exemplo n.º 2
0
class Gym(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), unique=True, nullable=False)
    address = db.Column(db.String(120), nullable=False)
    phone = db.Column(db.String(12), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    sessions = db.relationship("GymSession")

    def __repr__(self):
        return f"Gym('{self.name}', '{self.address}', '{self.phone}', '{self.email}')"

    def __init__(self, name, address, phone, email):
        self.name = name
        self.address = address
        self.phone = phone
        self.email = email
Exemplo n.º 3
0
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)
    password = db.Column(db.String(60), nullable=False)
    sessions = db.relationship("UserSession")

    def __repr__(self):
        return f"User('{self.username}', '{self.email}')"

    def hash_password(self, password):
        self.password = bcrypt.generate_password_hash(password).decode('utf-8')

    def __init__(self, username, email, password):
        self.username = username
        self.email = email
        self.password = password
Exemplo n.º 4
0
class Gym(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), unique=True, nullable=False)
    parent_gym = db.Column(db.String(20), nullable=False)
    location_X = db.Column(db.Float, nullable=False)
    location_Y = db.Column(db.Float, nullable=False)
    address = db.Column(db.String(120), nullable=False)
    phone = db.Column(db.String(12), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    sessions = db.relationship("GymSession")

    def __repr__(self):
        return f"Gym('{self.name}', '{self.parent_gym}', '{self.address}', '{self.phone}', '{self.email}')"
Exemplo n.º 5
0
class GymSession(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time_start = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.utcnow)
    time_end = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    gym_id = db.Column(db.Integer, db.ForeignKey("gym.id"), nullable=False)
    capacity = db.Column(db.Integer, nullable=False)
    spots_remaining = db.Column(db.Integer, nullable=False)
    activity = db.Column(db.String, nullable=False)

    def __repr__(self):
        return f"GymSession('{self.time_start}', '{self.time_end}', '{self.gym_id}', '{self.capacity}', '{self.sports_remaining}', '{activity}')"
Exemplo n.º 6
0
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)
    gym = db.Column(db.String(20), nullable=False)
    membership_id = db.Column(db.String(20), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    sessions = db.relationship("UserSession")

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.gym}', '{self.membership_id}')"