예제 #1
0
class OccasionalAgreement(RentalAgreement):
    __tablename__ = 'occasional_agreement'
    __mapper_args__ = {'polymorphic_identity': 'occasional_agreement'}

    id = db.Column(db.Integer,
                   db.ForeignKey('rental_agreement.id'),
                   primary_key=True,
                   nullable=False)
    notary_confirmation = db.Column(db.String(100))
예제 #2
0
파일: LandLord.py 프로젝트: wjureczka/MAS
class LandLord(User):
    __tablename__ = 'landlord'
    __mapper_args__ = {
        'polymorphic_identity': 'landlord',
    }

    id: int = db.Column(db.Integer,
                        db.ForeignKey('user.id'),
                        primary_key=True,
                        nullable=False)
    bank_account_number: str = db.Column(db.String(16), unique=True)
예제 #3
0
class RentalAgreement(db.Model):
    __tablename__ = 'rental_agreement'
    __mapper_args = {
        'polymorphic_identity': 'rental_agreement',
        'polymorphic_on': type
    }

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    start_date = db.Column(db.DATE)
    end_date = db.Column(db.DATE)
    rules_of_use = db.Column(db.String(300))

    rental_object_id = db.Column(db.Integer, db.ForeignKey('rental_object.id'))
    rental_object = db.relationship('RentalObject')
    bills: list = db.relationship('RentBill',
                                  back_populates='rental_agreement')
예제 #4
0
class CommonAgreement(RentalAgreement):
    __tablename__ = 'common_agreement'
    __mapper_args__ = {
        'polymorphic_identity': 'common_agreement'
    }

    id = db.Column(db.Integer, db.ForeignKey('rental_agreement.id'), primary_key=True, nullable=False)
예제 #5
0
class RentBill(db.Model):
    __tablename__ = 'rent_bill'

    date_of_payment = db.Column(db.DATE)
    due_date = db.Column(db.DATE, nullable=False)
    tenant_id = db.Column(db.Integer,
                          db.ForeignKey('tenant.id'),
                          primary_key=True,
                          nullable=False)
    tenant = db.relationship("Tenant", back_populates='bills')
    rental_agreement = db.relationship("RentalAgreement",
                                       back_populates='bills')
    rental_agreement_id = db.Column(db.Integer,
                                    db.ForeignKey('rental_agreement.id'),
                                    primary_key=True,
                                    nullable=False)
예제 #6
0
class Opinion(db.Model):
    __tablename__ = 'opinion'

    _available_rates = ("0", "1", "2", "3", "4", "5")

    comment: str = db.Column(db.String(200))
    rate: float = db.Column(db.Float)
    author_id = db.Column(db.Integer,
                          db.ForeignKey('tenant.id'),
                          primary_key=True,
                          nullable=False)
    author = db.relationship("Tenant", back_populates='opinions')
    rental_object = db.relationship("RentalObject", back_populates='opinions')
    rental_object_id = db.Column(db.Integer,
                                 db.ForeignKey('rental_object.id'),
                                 primary_key=True,
                                 nullable=False)
예제 #7
0
파일: Flat.py 프로젝트: wjureczka/MAS
class Flat(RentalObject):
    __tablename__ = 'flat'
    __mapper_args__ = {
        'polymorphic_identity': 'flat',
        'inherit_condition': id == RentalObject.id
    }

    id: int = db.Column(db.Integer,
                        db.ForeignKey('rental_object.id'),
                        primary_key=True,
                        nullable=False)
    rooms = db.relationship('Room')
예제 #8
0
class User(db.Model):
    __tablename__ = 'user'
    __mapper_args = {'polymorphic_identity': 'user', 'polymorphic_on': type}

    id: int = db.Column(db.Integer, primary_key=True, nullable=False)
    pesel = db.Column(db.String(11), unique=True, nullable=False)
    name: str = db.Column(db.String(50), nullable=False)
    surname = db.Column(db.String(50), nullable=False)
    email: str = db.Column(db.String(50), unique=True, nullable=False)
    password = db.Column(db.String(100), nullable=False)

    @validates('email')
    def validate_email(self, key, email):
        assert '@' in email, "Not valid email: email should contain '@'"
        return email

    @validates('password')
    def validate_password(self, key, password):
        assert password is not None, "Password can not be empty"
        return password

    @validates('pesel')
    def validate_pesel(self, key, pesel):
        assert len(pesel) == 11, "Bad pesel's length"
        return pesel

    @validates('name')
    def validate_name(self, key, name):
        assert name is not None, "Name can not be empty"
        return name

    @validates('surname')
    def validate_surname(self, key, surname):
        assert surname is not None, "Surname can not be empty"
        return surname
예제 #9
0
파일: Tenant.py 프로젝트: wjureczka/MAS
class Tenant(User):
    __tablename__ = 'tenant'
    __mapper_args__ = {'polymorphic_identity': 'tenant'}

    id: int = db.Column(db.Integer,
                        db.ForeignKey('user.id'),
                        primary_key=True,
                        nullable=False)
    groups: list = db.relationship('Group',
                                   secondary=User_Group,
                                   backref='Tenant')
    opinions: list = db.relationship('Opinion', back_populates='author')
    bills: list = db.relationship('RentBill', back_populates='tenant')
예제 #10
0
파일: Group.py 프로젝트: wjureczka/MAS
class Group(db.Model):
    __tablename__ = 'group'
    __table_args__ = {'extend_existing': True}

    users: list = db.relationship('Tenant',
                                  secondary=User_Group,
                                  backref='Group')

    id: int = db.Column(db.Integer, primary_key=True)
    name: str = db.Column(db.String(100), nullable=False)
    preferred_locations: str = db.Column(db.String(100))
    preferred_room_quantity: int = db.Column(db.Integer)
    preferred_size: int = db.Column(db.Integer)
    budget: int = db.Column(db.Integer)
예제 #11
0
class RentalObject(db.Model):
    __tablename__ = 'rental_object'
    __mapper_args = {
        'polymorphic_identity': 'rental_object',
        'polymorphic_on': type
    }

    id: int = db.Column(db.Integer, primary_key=True, nullable=False)
    description: str = db.Column(db.String(200))
    area_description: str = db.Column(db.String(200))
    equipment: str = db.Column(db.String(200))
    address: str = db.Column(db.String)
    price: float = db.Column(db.Float)
    opinions: list = db.relationship('Opinion', back_populates='rental_object')
예제 #12
0
from MAS.application import db

User_Group = db.Table(
    'user_group', db.Column('id', db.Integer, primary_key=True),
    db.Column('tenant_id',
              db.Integer,
              db.ForeignKey('tenant.id'),
              nullable=False),
    db.Column('group_id',
              db.Integer,
              db.ForeignKey('group.id'),
              nullable=False))