Exemple #1
0
class Client(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    firstName = db.Column(db.String(40))
    lastName = db.Column(db.String(40))
    email = db.Column(db.Integer, db.ForeignKey('email.id'), nullable=False)
    notes = db.relationship('Note',
                            secondary=clientNote,
                            backref=db.backref('client', lazy='dynamic'))
    tickets = db.relationship('Ticket',
                              secondary=clientTicket,
                              backref=db.backref('client', lazy='dynamic'))
    phones = db.relationship('Phone',
                             secondary=clientPhone,
                             backref=db.backref('client', lazy='dynamic'))
Exemple #2
0
class Phone(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    number = db.Column(db.String(10), unique=True, nullable=False)
    phoneType = db.relationship('PhoneType',
                                backref='phone',
                                lazy=True,
                                uselist=False)
Exemple #3
0
class Organization(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False, unique=True)
    isActive = db.Column(db.Boolean, nullable=False)
    address = db.Column(db.Integer,
                        db.ForeignKey('organization.id'),
                        nullable=False)
    phone = db.relationship('Phone',
                            secondary=orgPhone,
                            backref='organization',
                            lazy='dynamic')
Exemple #4
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(25), unique=True, nullable=False)
    password = db.Column(db.String(64), nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.png')
    email = db.Column(db.String(120), unique=True, nullable=False)
    fName = db.Column(db.String(40), nullable=False)
    lName = db.Column(db.String(40), nullable=False)
    isActive = db.Column(db.Boolean)
    #themes    = db.relationship('Theme', backref='user', lazy=True, uselist=False)
    groups = db.relationship('Group',
                             secondary=userGroup,
                             backref=db.backref('user', lazy='dynamic'))
Exemple #5
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    password = db.Column(db.String(64), nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.png')
    email = db.Column(db.String(120), unique=True, nullable=False)
    fName = db.Column(db.String(40), nullable=False)
    lName = db.Column(db.String(40), nullable=False)
    isActive = db.Column(db.Boolean, nullable=False)
    group_id = db.Column(db.Integer, db.ForeignKey('group.id'), nullable=False)
    group = db.relationship('Group',
                            backref=db.backref('users',
                                               uselist=True,
                                               cascade='delete,all'))

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}