Пример #1
0
class TMessage(db.Model, CRUDMixin, Timestamp):
    __tablename__ = "tMessage"

    ixMessage = db.Column(db.Integer, primary_key=True)
    ixLog = db.Column(db.Integer,
                      db.ForeignKey("tLog.ixLog", ondelete="CASCADE"),
                      nullable=False)
    log = db.relationship("TLog", uselist=False)
    ixMessageType = db.Column(db.Integer,
                              db.ForeignKey("tMessageType.ixMessageType"),
                              nullable=False)
    message_type = db.relationship("TMessageType", uselist=False)

    ixUser = db.Column(db.Integer,
                       db.ForeignKey("tUser.ixUser", ondelete="CASCADE"),
                       nullable=False)
    user = db.relationship("TUser", uselist=False)

    # utcMessage is added for being able to change some history if a note was missed
    utcMessage = db.Column(db.DateTime,
                           default=datetime.utcnow,
                           nullable=False)
    sMessage = db.Column(db.Text)

    # TODO: need to test this relationship
    user_permissions = db.relationship(
        "TUserPermission",
        primaryjoin=("and_(foreign(TMessage.ixLog) == TUserPermission.ixLog, "
                     "TMessage.ixUser == TUserPermission.ixUser)"),
    )
    tags = db.relationship("TTag", secondary="tTagMessage")
Пример #2
0
class TUserRole(db.Model, CRUDMixin):
    __tablename__ = "tUserRole"

    ixUser = db.Column(db.Integer,
                       db.ForeignKey("tUser.ixUser"),
                       primary_key=True)
    user = db.relationship("TUser")

    ixRole = db.Column(db.Integer,
                       db.ForeignKey("tRole.ixRole"),
                       primary_key=True)
    role = db.relationship("TRole")
Пример #3
0
class TLogField(db.Model, CRUDMixin):
    __tablename__ = "tLogField"

    ixLogField = db.Column(db.Integer, primary_key=True)
    ixField = db.Column(db.Integer, db.ForeignKey("tField.ixField"))
    field = db.relationship("TField", uselist=False)
    ixLog = db.Column(db.Integer, db.ForeignKey("tLog.ixLog"))
    log = db.relationship("TLog", uselist=False)
    sValue = db.Column(db.Unicode)
    iOrder = db.Column(db.Integer)

    __table_args__ = (db.UniqueConstraint("ixField",
                                          "ixLog",
                                          name="uq_tlogfield_ixfield_ixlog"), )
Пример #4
0
class TRolePermission(db.Model, CRUDMixin):
    __tablename__ = "tRolePermission"

    ixRolePermission = db.Column(db.Integer, primary_key=True)
    ixLog = db.Column(db.Integer, db.ForeignKey("tLog.ixLog"), nullable=False)
    log = db.relationship("TLog", uselist=False)

    ixRole = db.Column(db.Integer,
                       db.ForeignKey("tRole.ixRole"),
                       nullable=False)
    user = db.relationship("TRole", uselist=False)

    ixAction = db.Column(db.Integer,
                         db.ForeignKey("tAction.ixAction"),
                         nullable=False)
    action = db.relationship("TAction", uselist=False)
Пример #5
0
class TRole(db.Model, CRUDMixin):
    __tablename__ = "tRole"

    ixRole = db.Column(db.Integer, primary_key=True)
    sRole = db.Column(db.Unicode(80), unique=True)
    sDescription = db.Column(db.Text)

    users = db.relationship("TUser", secondary="tUserRole")
Пример #6
0
class TLog(db.Model, CRUDMixin, Timestamp):
    __tablename__ = "tLog"

    ixLog = db.Column(db.Integer, primary_key=True)
    sLog = db.Column(db.Unicode)
    ixUser = db.Column(db.Integer,
                       db.ForeignKey("tUser.ixUser"),
                       nullable=False)
    user = db.relationship("TUser", uselist=False)

    fields = db.relationship("TLogField", uselist=True)

    user_permissions = db.relationship(
        "TUserPermission",
        primaryjoin=
        "and_(TLog.ixLog == TUserPermission.ixLog, TLog.ixUser == TUserPermission.ixUser)",
    )
    role_permissions = db.relationship("TRolePermission")
Пример #7
0
class TUser(db.Model, CRUDMixin, Timestamp):
    __tablename__ = "tUser"

    ixUser = db.Column(db.Integer, primary_key=True)
    sEmail = db.Column(EmailType, unique=True, nullable=False)
    sName = db.Column(db.Unicode(255))
    urlProfilePic = db.Column(URLType)
    urlDefaultLog = db.Column(URLType)
    fs_uniquifier = db.Column(db.Text, unique=True)

    roles = db.relationship("TRole", secondary="tUserRole")
    user_permissions = db.relationship("TUserPermission")
    role_permissions = db.relationship(
        "TRolePermission",
        secondary="tUserRole",
        primaryjoin=("TUser.ixUser == TUserRole.ixUser"),
        secondaryjoin=("TUserRole.ixRole == TRolePermission.ixRole"),
    )
Пример #8
0
class TTagMessage(db.Model, CRUDMixin):
    __tablename__ = "tTagMessage"

    ixMessage = db.Column(db.Integer,
                          db.ForeignKey("tMessage.ixMessage"),
                          primary_key=True)
    ixTag = db.Column(db.Integer,
                      db.ForeignKey("tTag.ixTag"),
                      primary_key=True)
    tag = db.relationship("TTag", uselist=False)