示例#1
0
class Info(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    gym_id = db.Column(db.Integer, db.ForeignKey('gym.id'))
    search_id = db.Column(db.Integer, db.ForeignKey('search.id'))
    link = db.Column(db.String(300))
    description = db.Column(db.String(100))

    def __repr__(self):
        return "Info({}:{})".format(self.id, self.gym.name)
示例#2
0
class Gym(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    search_id = db.Column(db.Integer, db.ForeignKey('search.id'))
    name = db.Column(db.String(60))
    locations = db.relationship('Location', backref='gym', lazy='subquery')
    info = db.relationship("Info", backref='gym', lazy='subquery')

    def __repr__(self):
        return "Gym({})".format(self.name)
示例#3
0
class Employee(db.Model, UserMixin):
	id = db.Column(db.Integer, primary_key=True)
	fname = db.Column(db.String(30), nullable=False)
	lname = db.Column(db.String(30), nullable=False)
	email = db.Column(db.String(100), unique=True, nullable=False)
	phone = db.Column(db.String(15), unique=True, nullable=False)
	role = db.Column(db.String(20), nullable=False)
	password = db.Column(db.String(60), nullable=False)

	salary = db.Column(db.Float)
	incentive = db.Column(db.Float)
	students = db.relationship('User', backref='coach', lazy=True)


	def get_reset_token(self, expires_sec=1800):
		s = Serializer(app.config['SECRET_KEY'], expires_sec)
		return s.dumps({'emp_id': self.id}).decode('utf-8')

	@staticmethod
	def verify_reset_token(token):
		s = Serializer(app.config['SECRET_KEY'])
		try:
			emp_id = s.loads(token)['emp_id']
		except:
			return None
		return Employee.query.get(emp_id)


	def __repr__(self):
		return f"Coach( {self.fname} {self.lname} )"
示例#4
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = 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.date_posted}')"
示例#5
0
class Search(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_input = db.Column(db.String(100), nullable=False)
    gyms = db.relationship("Gym",
                           secondary=search_gym,
                           lazy='subquery',
                           backref=db.backref('searches', lazy=True))
    lat = db.Column(db.Float)
    lng = db.Column(db.Float)

    def __repr__(self):
        return "Search({})".format(self.user_input)
示例#6
0
class Location(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    search_id = db.Column(db.Integer, db.ForeignKey('search.id'))
    gym_id = db.Column(db.Integer, db.ForeignKey('gym.id'))
    #place id is a string used by Google place details api to look for more detailsyyy
    place_id = db.Column(db.String(60))
    #this will link to google maps
    link = db.Column(db.String(150))
    address = db.Column(db.String(60))
    lat = db.Column(db.Float)
    lng = db.Column(db.Float)

    def __repr__(self):
        return "Location({} location at {})".format(self.gym.name,
                                                    self.address)
示例#7
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)
    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 get_reset_token(self, expires_sec=1800):
        s = Serializer(current_app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    def verify_reset_token(token):
        s = Serializer(current_app.config['SECRET_KEY'], expires_sec)
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
示例#8
0
class User(db.Model, UserMixin):
	# UserMixin manages our sessions
	id = db.Column(db.Integer, primary_key=True)
	fname = db.Column(db.String(50), nullable=False)
	lname = db.Column(db.String(50), nullable=False)
	email = db.Column(db.String(100), unique=True, nullable=False)
	phone = db.Column(db.String(15), unique=True)
	gender = db.Column(db.String(10), nullable=False)
	birth_year = db.Column(db.Integer)
	password = db.Column(db.String(60), nullable=False) 
	employee_id = db.Column(db.Integer, db.ForeignKey('employee.id'))

	rate = db.Column(db.Integer)

	sup_start = db.Column(db.DateTime) 
	sup_end = db.Column(db.DateTime) 
	freeze = db.Column(db.Boolean, default=False)
	#datetime.utcnow
	months = db.Column(db.Integer)
	payment = db.Column(db.Float, default=0.0)
	change = db.Column(db.Float, default=0.0)
	discount = db.Column(db.Float, default=0.0)
	points = db.Column(db.Integer, default=0)



	def get_reset_token(self, expires_sec=1800):
		s = Serializer(app.config['SECRET_KEY'], expires_sec)
		return s.dumps({'user_id': self.id}).decode('utf-8')

	@staticmethod
	def verify_reset_token(token):
		s = Serializer(app.config['SECRET_KEY'])
		try:
			user_id = s.loads(token)['user_id']
		except:
			return None
		return User.query.get(user_id)

	def __repr__(self):
		return f"Trainer( {self.fname} {self.lname} )"
示例#9
0
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = 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.date_posted}')"


#table used to define the many to many relationship bewteen Search and Gym
#with one search, we get many gyms and with one gym we can have many searches
search_gym = db.Table(
    'search_gym',
    db.Column('search_id',
              db.Integer,
              db.ForeignKey('search.id'),
              primary_key=True),
    db.Column('gym_id', db.Integer, db.ForeignKey('gym.id'), primary_key=True))


class Search(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_input = db.Column(db.String(100), nullable=False)
    gyms = db.relationship("Gym",
                           secondary=search_gym,
                           lazy='subquery',
                           backref=db.backref('searches', lazy=True))
    lat = db.Column(db.Float)
    lng = db.Column(db.Float)

    def __repr__(self):