Exemplo n.º 1
0
class Alias(db.Model):
    alias = db.Column(db.String(128), primary_key=True, nullable=False)
    command = db.Column(db.String(128), nullable=False)
    badge = db.Column(db.String(128), nullable=False)

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Exemplo n.º 2
0
class GroupAlert(db.Model):
    group_name = db.Column(db.String(128), primary_key=True, nullable=False)
    alerts = db.relationship('GroupAlertAssociation',
                             cascade='all,delete',
                             backref='group_alert')
    thumbnail = db.Column(db.String(128))
    current_index = db.Column(db.Integer, default=0)
    counts = db.relationship('Count', backref='group_alert')
    always_chat = db.Column(db.Boolean,
                            default=False,
                            nullable=False,
                            server_default='f')
    chat_message = db.Column(db.String(128))

    def as_dict(self):
        name = getattr(self, 'group_name')
        alerts_query = db.session.query(GroupAlertAssociation.alert_name).filter_by(group_name=name)\
            .order_by(GroupAlertAssociation.index)
        alerts = [result[0] for result in alerts_query]
        thumbnail = getattr(self, 'thumbnail')
        always_chat = getattr(self, 'always_chat')
        chat_message = getattr(self, 'chat_message')
        return {
            'name': name,
            'alerts': alerts,
            'thumbnail': thumbnail,
            'always_chat': always_chat,
            'chat_message': chat_message
        }
Exemplo n.º 3
0
class Count(db.Model):
    name = db.Column(db.String(128), primary_key=True, nullable=False)
    count = db.Column(db.Integer, default=0)
    group_name = db.Column(
        db.String(128),
        ForeignKey('group_alert.group_name', name='group_alert_count_fk'))

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Exemplo n.º 4
0
class ListItem(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    list_name = db.Column(db.String(128),
                          db.ForeignKey('list.name'),
                          nullable=False)
    index = db.Column(db.Integer, nullable=False)
    item = db.Column(db.String(128), nullable=False)

    __table_args__ = (db.UniqueConstraint('list_name',
                                          'index',
                                          name='_lists_uc'), )
Exemplo n.º 5
0
class GroupAlertAssociation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    group_name = db.Column(db.String(128),
                           db.ForeignKey('group_alert.group_name'),
                           nullable=False)
    alert_name = db.Column(db.String(128),
                           db.ForeignKey('alert.name'),
                           nullable=False)
    index = db.Column(db.Integer)
    __table_args__ = (db.UniqueConstraint('group_name',
                                          'alert_name',
                                          name='_group_alert_uc'), )
Exemplo n.º 6
0
class List(db.Model):
    name = db.Column(db.String(128), primary_key=True, nullable=False)
    items = db.relationship('ListItem',
                            cascade='all,delete',
                            backref='group_alert')
    current_index = db.Column(db.Integer, default=0)

    def as_dict(self):
        name = getattr(self, 'name')
        items_query = db.session.query(
            ListItem.item).filter_by(list_name=name).order_by(ListItem.index)
        items = [result[0] for result in items_query]
        return {'name': name, 'items': items}
Exemplo n.º 7
0
class Alert(db.Model):
    name = db.Column(db.String(128), primary_key=True, nullable=False)
    text = db.Column(db.String(128))
    sound = db.Column(db.String(128))
    image = db.Column(db.String(128))
    duration = db.Column(db.Integer, default=500)
    thumbnail = db.Column(db.String(128))
    effect = db.Column(db.String(128))

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Exemplo n.º 8
0
class Timer(db.Model):
    command = db.Column(db.String(128), primary_key=True, nullable=False)
    interval = db.Column(db.Integer(), nullable=False)

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