Example #1
0
class City(db.Model):
    __tablename__ = 'cities'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    zipcode = db.Column(db.String, nullable=False)
    created = db.Column(db.DateTime,
                        nullable=False,
                        server_default=db.func.current_timestamp())

    cleaners = relationship('Cleaner',
                            secondary=cleaners_cities,
                            back_populates='cities')
Example #2
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String, unique=True, nullable=False)
    _password = db.Column("password", db.String, nullable=False)

    @hybrid_property
    def password(self):
        return self._password

    @password.setter
    def password(self, value):
        """Store the password as a hash for security."""
        self._password = generate_password_hash(value)

    def check_password(self, value):
        return check_password_hash(self.password, value)
Example #3
0
class Booking(db.Model):
    __tablename__ = 'bookings'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False)

    city_id = db.Column(db.ForeignKey(City.id), nullable=False)
    city = db.relationship(City, lazy="joined", backref="bookings")

    cleaner_id = db.Column(db.ForeignKey(Cleaner.id), nullable=False)
    cleaner = db.relationship(Cleaner, lazy="joined", backref="bookings")

    name = db.Column(db.String, nullable=False)
    email = db.Column(db.String, nullable=False)
    phone = db.Column(db.String, nullable=False)

    created = db.Column(db.DateTime,
                        nullable=False,
                        server_default=db.func.current_timestamp())
Example #4
0
from cleanup.database import db

# Association table for cleaners and cities
cleaners_cities = db.Table(
    'cleaners_cities',
    db.Column('cleaner_id', db.ForeignKey('cleaners.id'), primary_key=True),
    db.Column('city_id', db.ForeignKey('cities.id'), primary_key=True)
)