示例#1
0
class CarLicence(db.Model):
    __tablename__ = 'car_licence'
    licence_id = db.Column(db.Integer, primary_key=True)
    photo = db.Column(db.LargeBinary, nullable=False)
    assistant_id = db.Column(db.ForeignKey('assistant.assistant_id'))
    assistant = db.relationship(
        'Assistant',
        primaryjoin='CarLicence.assistant_id == Assistant.assistant_id',
        backref='car_licences')
示例#2
0
class BlindNationalId(db.Model):
    __tablename__ = 'blind_national_id'
    id = db.Column(db.Integer, primary_key=True)
    photo = db.Column(db.LargeBinary, nullable=False)
    blind_id = db.Column(db.ForeignKey('blind.blind_id'), nullable=False)

    blind = db.relationship(
        'Blind',
        primaryjoin='BlindNationalId.blind_id == Blind.blind_id',
        backref='blind_national_ids')
示例#3
0
class AssistantNationalId(db.Model):
    __tablename__ = 'assistant_national_id'
    id = db.Column(db.Integer, primary_key=True)
    photo = db.Column(db.LargeBinary, nullable=False)
    assistant_id = db.Column(db.ForeignKey('assistant.assistant_id'))
    assistant = db.relationship(
        'Assistant',
        primaryjoin=
        'AssistantNationalId.assistant_id == Assistant.assistant_id',
        backref='assistant_national_ids')
示例#4
0
class TrustedNationalId(db.Model):
    __tablename__ = 'trusted_national_id'
    id = db.Column(db.Integer, primary_key=True)
    photo = db.Column(db.LargeBinary, nullable=False)
    trusted_id = db.Column(db.ForeignKey('trusted_person.trusted_id'),
                           nullable=False)
    trusted = db.relationship(
        'TrustedPerson',
        primaryjoin='TrustedNationalId.trusted_id == TrustedPerson.trusted_id',
        backref='trusted_national_ids')
示例#5
0
class TrustedPerson(db.Model):
    __tablename__ = 'trusted_person'
    trusted_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text, nullable=False)
    phone = db.Column(db.Text(11), nullable=False)
    relation = db.Column(db.Text, nullable=False)
    blind_id = db.Column(db.ForeignKey('blind.blind_id'), nullable=False)
    blind = db.relationship(
        'Blind',
        primaryjoin='TrustedPerson.blind_id == Blind.blind_id',
        backref='trusted_people')
示例#6
0
class Assistant(db.Model):
    __tablename__ = 'assistant'

    assistant_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text, nullable=False)
    phone = db.Column(db.Text(11), nullable=False)
    region = db.Column(db.Text, nullable=False)
    photo = db.Column(db.LargeBinary)
    e_mail = db.Column('e-mail', db.Text, nullable=False, unique=True)
    password = db.Column(db.Text, nullable=False)
    availability = db.Column(db.Boolean, server_default=db.FetchedValue())
    current_location = db.Column(db.Text)
    number_of_trips = db.Column(db.Integer, server_default=db.FetchedValue())
示例#7
0
class Blind(db.Model):
    __tablename__ = 'blind'
    blind_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text, nullable=False)
    phone = db.Column(db.Text(11), nullable=False)
    region = db.Column(db.Text, nullable=False)
    email = db.Column('email', db.Text, nullable=False, unique=True)
    password = db.Column(db.Text, nullable=False)
    number_of_trips = db.Column(db.Integer)
示例#8
0
class Assistant(db.Model):
    __tablename__ = 'assistant'
    assistant_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text, nullable=False)
    phone = db.Column(db.Text(11), nullable=False)
    region = db.Column(db.Text, nullable=False)
    photo = db.Column(db.LargeBinary)
    email = db.Column('email', db.Text, nullable=False, unique=True)
    password = db.Column(db.Text, nullable=False)
    availability = db.Column(db.Boolean, server_default=db.FetchedValue())
    current_location = db.Column(db.Text)
    number_of_trips = db.Column(db.Integer, server_default=db.FetchedValue())

    def hash_password(self, password):
        self.password = pwd_context.encrypt(password)

    def verify_password(self, password):
        self.password = pwd_context.verify(password, self.password)

    def generate_auth_token(self, expiration=600):
        s = Serializer(secret_key, expires_in=expiration)
        return s.dumps({'id': self.id})

    @staticmethod
    def verify_auth_token(token):
        s = Serializer(secret_key)
        try:
            data = s.loads(token)
        except SignatureExpired:
            # Valid Token, but expired
            return None
        except BadSignature:
            # Invalid Token
            return None
        assistant_id = data['id']
        return assistant_id
示例#9
0
class Trip(db.Model):
    __tablename__ = 'trips'

    trip_id = db.Column(db.Integer, primary_key=True)
    complete = db.Column(db.Boolean, nullable=False)
    state = db.Column(db.Boolean, nullable=False)
    total_distance = db.Column(db.Integer, nullable=False)
    total_time = db.Column(db.Integer, nullable=False)
    payment = db.Column(db.Float(2), nullable=False)
    request_id = db.Column(db.ForeignKey('request.request_id'))

    request = db.relationship(
        'Request',
        primaryjoin='Trip.request_id == Request.request_id',
        backref='trips')
示例#10
0
class Request(db.Model):
    __tablename__ = 'request'

    request_id = db.Column(db.Integer, primary_key=True)
    type_of_service = db.Column(db.String, nullable=False)
    current_location = db.Column(db.Text, nullable=False)
    accepted = db.Column(db.Boolean, nullable=False)
    distenation_ = db.Column('distenation ', db.Text, nullable=False)
    time_needed = db.Column(db.Integer, nullable=False)
    blind_id = db.Column(db.ForeignKey('blind.blind_id'))
    assistant_id = db.Column(db.ForeignKey('assistant.assistant_id'))

    assistant = db.relationship(
        'Assistant',
        primaryjoin='Request.assistant_id == Assistant.assistant_id',
        backref='requests')
    blind = db.relationship('Blind',
                            primaryjoin='Request.blind_id == Blind.blind_id',
                            backref='requests')