Beispiel #1
0
class FolderHeaderCacheItem(db.Model):
    '''
    Email header data, attached to the relevant folder.
    '''

    __bind_key__ = 'folders'
    __tablename__ = 'folder_header_cache_item'
    __table_args__ = (
        db.UniqueConstraint('uid', 'folder_id'),
    )

    id = db.Column(db.Integer, primary_key=True)

    uid = db.Column(db.Integer, nullable=False, index=True)
    data = db.Column(db.Text, nullable=False)

    folder_id = db.Column(
        db.Integer,
        db.ForeignKey('folder_cache_item.id', ondelete='CASCADE'),
        nullable=False,
    )
    folder = db.relationship('FolderCacheItem')

    def __str__(self):
        return f'{self.folder}/{self.uid}'
Beispiel #2
0
class AllowedImage(db.Model):
    __bind_key__ = 'contacts'
    __tablename__ = 'allowed_images'
    __table_args__ = (db.UniqueConstraint('email'), )

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(300))
Beispiel #3
0
class Contact(db.Model):
    __bind_key__ = 'contacts'
    __tablename__ = 'contacts'
    __table_args__ = (db.UniqueConstraint('email', 'name'), )

    id = db.Column(db.Integer, primary_key=True)

    name = db.Column(db.String(300))
    email = db.Column(db.String(300))

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'email': self.email,
        }
Beispiel #4
0
class FolderCacheItem(db.Model):
    '''
    Store folder UID list and validity.
    '''

    __bind_key__ = 'folders'
    __tablename__ = 'folder_cache_item'
    __table_args__ = (db.UniqueConstraint('account_name', 'folder_name'), )

    id = db.Column(db.Integer, primary_key=True)

    account_name = db.Column(db.String(300), nullable=False)
    folder_name = db.Column(db.String(300), nullable=False)

    uid_validity = db.Column(db.String(300))
    uids = db.Column(db.Text)