Exemplo n.º 1
0
class Group(BaseUser):
    __tablename__ = "group"

    active = db.Column(db.Boolean, nullable=False, default=False)
    name = db.Column(db.String(100))
    description = db.Column(db.String(255))
    admin = db.Column(db.Boolean, nullable=False, default=False)

    def __repr__(self):
        return "<Group %r : %r>" % self.id, self.name
Exemplo n.º 2
0
class Role(BaseUser):
    __tablename__ = "role"

    name = db.Column(db.String(100), nullable=False, unique=True)
    description = db.Column(db.String(150), nullable=False)

    # if not otherwise stated on the target resource. e.g. monitoring users would be implicit UnixPermission.READ
    # this is here to act like a mask -- so we can prevent a "demo users" Role from being able to write changes to
    # and endpoint that someone forgot to lock down.
    implicit_access = db.Column(db.Enum(UnixPermission), default=UnixPermission.READ)
    super_admin = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return '<Role %r>' % self.name
Exemplo n.º 3
0
Arquivo: models.py Projeto: idjaw/yams
class BaseDashboardUnit(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    active = db.Column(db.Boolean, nullable=False, default=True)
    last_updated = db.Column(db.DateTime, default=datetime.utcnow)

    @declared_attr
    def owner_user_id(cls):
        return db.Column(db.Integer, db.ForeignKey("user.id"))

    @declared_attr
    def owner_group_id(cls):
        return db.Column(db.Integer, db.ForeignKey("group.id"))

    permission_user = db.Column(db.Enum(UnixPermission),
                                default=UnixPermission.READ_WRITE)
    permission_group = db.Column(db.Enum(UnixPermission),
                                 default=UnixPermission.READ)
    permission_other = db.Column(db.Enum(UnixPermission),
                                 default=UnixPermission.NONE)

    # if the panel is private and there's a user_id, it shouldn't be available to other users
    user_id = db.Column("user_id", db.Integer, default=0)
    private = db.Column(db.Boolean, nullable=False, default=False)
Exemplo n.º 4
0
class Group(db.Model):
    __tablename__ = "group"
    _id = db.Column("id", db.Integer, primary_key=True)
    uid = db.relationship("User",
                          secondary=uid_gid_association,
                          backref="group")

    active = db.Column(db.Boolean, nullable=False, default=False)
    name = db.Column(db.String(100))
    description = db.Column(db.String(500))
    admin = db.Column(db.Boolean, nullable=False, default=False)

    def __repr__(self):
        return "<Group %r : %r>" % self.id, self.name
Exemplo n.º 5
0
Arquivo: models.py Projeto: idjaw/yams
class yamsBoxPanel(BaseDashboardUnitWithText):
    __tablename__ = "yams_box_panel"

    # should simplify the isinstance checking in the code
    display_position = db.Column(db.Integer, nullable=False, default=0)

    def __repr__(self):
        return "<yamsBoxGroupPanel %r : %r %r>" % self.id, self.active, self.last_updated
Exemplo n.º 6
0
Arquivo: models.py Projeto: idjaw/yams
class yamsBoxGroup(BaseDashboardUnitWithText):
    __tablename__ = "yams_box_group"

    # boxgroups are associated with a single yamsBoxGroupPanel
    yams_box_panel_id = db.Column(db.Integer,
                                  db.ForeignKey('yams_box_panel.id'))

    def __repr__(self):
        return "<yamsBoxGroup %r : %r %r>" % self.id, self.active, self.last_updated
Exemplo n.º 7
0
class User(db.Model):
    __tablename__ = "user"

    _id = db.Column("id", db.Integer, primary_key=True)
    usercontact_id = db.relationship("UserContact",
                                     uselist=False,
                                     backref="user")

    password_hash = db.Column(db.String(255), nullable=False)

    active = db.Column(db.Boolean, nullable=False, default=False)
    super_admin = db.Column(db.Boolean, default=False)
    last_updated = db.Column("last_updated",
                             db.DateTime,
                             default=datetime.utcnow())

    def __repr__(self):
        return "<User %r : %r %r>" % self.id, self.first_name, self.last_name
Exemplo n.º 8
0
class UserContact(db.Model):

    __tablename__ = "user_contact"

    _id = db.Column("id", db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    first_name = db.Column(db.String(50), default="", unique=True)
    last_name = db.Column(db.String(50), default="", unique=True)
    description = db.Column(db.String(500))

    # string because ext. #
    phone_number = db.Column(db.String(50))
    skype_handle = db.Column(db.String(100))
    google_handle = db.Column(db.String(100))
    email_address = db.Column(db.String(200), unique=True)
Exemplo n.º 9
0
class User(BaseUser):
    __tablename__ = "user"

    first_name = db.Column(db.String(50))
    last_name = db.Column(db.String(50))
    description = db.Column(db.String(255))

    # string because ext. #
    phone_number = db.Column(db.String(100))
    skype_handle = db.Column(db.String(100))
    google_handle = db.Column(db.String(100))
    email_address = db.Column(db.String(255), unique=True)

    password_hash = db.Column(db.String(255), nullable=False)
    active = db.Column(db.Boolean, nullable=False, default=False)

    def __repr__(self):
        return "<User %r : %r %r>" % self.id, self.email_address, self.active
Exemplo n.º 10
0
class BaseUser(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True)
    time_created = db.Column(db.DateTime, default=datetime.utcnow)
    time_modified = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
Exemplo n.º 11
0

class UnixPermission(Enum):
    READ = 1
    WRITE = 2
    EXECUTE = 4
    NONE = 0
    READ_WRITE = READ + WRITE
    READ_EXECUTE = READ + EXECUTE
    ALL = READ + WRITE + EXECUTE

# users have multiple groups, groups can have multiple people
uid_gid_association = db.Table(
    'mapping_user_group',
    db.metadata,
    db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('group_id', db.Integer, db.ForeignKey('group.id'))
)

# groups can have multiple roles, permissions have multiple groups
gid_rid_association = db.Table(
    'mapping_group_role',
    db.metadata,
    db.Column('group_id', db.Integer, db.ForeignKey('group.id')),
    db.Column('role_id', db.Integer, db.ForeignKey('role.id'))
)


class BaseUser(db.Model):
    __abstract__ = True
Exemplo n.º 12
0
Arquivo: models.py Projeto: idjaw/yams
class yamsBox(BaseDashboardUnitWithText):
    __tablename__ = "yams_box"

    # 25%....2500px, etc.
    display_width = db.Column(db.String(10))
    display_height = db.Column(db.String(10))
    display_position = db.Column(db.Integer)

    data_update_interval_seconds = db.Column(db.Integer, default=300)
    data_update_method_type = db.Column(db.String(50))  # e.g. polling, etc
    data_endpoint_path = db.Column(db.String(255))
    data_metric_type = db.Column(db.String(50))  # e.g. "spot" or "series"

    response_logic = db.Column(db.String(50))  # e.g. boolean for up/down
    response_search_path = db.Column(db.String(1000))
    response_search_path_datatype = db.Column(db.String(100))
    response_search_path_extended_detail = db.Column(db.String(1000))
    response_display_typehint = db.Column(
        db.String(100))  # e.g. "list" or "graph"

    # enabled = super().active

    def __repr__(self):
        return "<yamsBox %r : %r %r>" % self.id, self.active, self.last_updated
Exemplo n.º 13
0
Arquivo: models.py Projeto: idjaw/yams
 def owner_group_id(cls):
     return db.Column(db.Integer, db.ForeignKey("group.id"))
Exemplo n.º 14
0
Arquivo: models.py Projeto: idjaw/yams
 def owner_user_id(cls):
     return db.Column(db.Integer, db.ForeignKey("user.id"))
Exemplo n.º 15
0
Arquivo: models.py Projeto: idjaw/yams

# display is currently:

# yamsPanel ~= row
#   inside a yamsPanel is a yamsBoxGroup
#       inside a yamsBoxGroup is N yamsBox

# yamsPanels/rows are ordered vertically.
# yamsBoxes are ordered positionally in their group "horizontally"

# a yamsBox is potentially many to many to a yamsBoxGroup  (if not, we'd have duplicate rows to present the same content).
# e.g. linking Github and AWS in 'deploy' group, or AWS and Netflix
yamsbox_yamsboxgroup_association = db.Table(
    'mapping_yams_box__yams_box_group', db.metadata,
    db.Column('yams_box_id', db.Integer, db.ForeignKey('yams_box.id')),
    db.Column('yams_box_group_id', db.Integer,
              db.ForeignKey('yams_box_group.id')))


class BaseDashboardUnit(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    active = db.Column(db.Boolean, nullable=False, default=True)
    last_updated = db.Column(db.DateTime, default=datetime.utcnow)

    @declared_attr
    def owner_user_id(cls):
        return db.Column(db.Integer, db.ForeignKey("user.id"))
Exemplo n.º 16
0
Arquivo: models.py Projeto: idjaw/yams
class BaseDashboardUnitWithText(BaseDashboardUnit):
    __abstract__ = True

    name = db.Column(db.String(100))
    description = db.Column(db.String(255))
Exemplo n.º 17
0
# try to use Flask-SQLAlchemy before heading down this path
#from sqlalchemy.ext.declarative import declarative_base
#Base = declarative_base()


class UnixPermission:
    READ = 1
    WRITE = 2
    EDIT = 4
    READ_WRITE = READ + WRITE
    ALL = READ + WRITE + EDIT


uid_gid_association = db.Table(
    'gid_uid_mapping', db.metadata,
    db.Column('uid', db.Integer, db.ForeignKey('user.id')),
    db.Column('gid', db.Integer, db.ForeignKey('group.id')))


class User(db.Model):
    __tablename__ = "user"

    _id = db.Column("id", db.Integer, primary_key=True)
    usercontact_id = db.relationship("UserContact",
                                     uselist=False,
                                     backref="user")

    password_hash = db.Column(db.String(255), nullable=False)

    active = db.Column(db.Boolean, nullable=False, default=False)
    super_admin = db.Column(db.Boolean, default=False)