Esempio n. 1
0
class BlogTypeMapped(Base, BlogType):
    '''
    Provides the mapping for Blog.
    '''
    __tablename__ = 'livedesk_blog_type'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Name = Column('name', String(255), nullable=False)
Esempio n. 2
0
class Signature(Base):
    '''
    Provides the ACL type signature mapping.
    '''
    __tablename__ = 'acl_signature'
    __table_args__ = dict(mysql_engine='InnoDB')
    
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    name = Column('name', String(255), nullable=False, unique=True)
Esempio n. 3
0
class Method(Base):
    '''
    Provides the ACL method mapping.
    '''
    __tablename__ = 'acl_method'
    __table_args__ = dict(mysql_engine='InnoDB')
    
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    name = Column('name', String(20), nullable=False, unique=True)
Esempio n. 4
0
class BlogSyncMapped(Base, BlogSync):
    '''
    Provides the mapping for BlogCollaborator definition.
    '''
    __tablename__ = 'livedesk_blog_sync'
    __table_args__ = (UniqueConstraint('fk_blog_id',
                                       'fk_source_id',
                                       name='uix_sync_blog_source'),
                      dict(mysql_engine='InnoDB', mysql_charset='utf8'))

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Blog = Column('fk_blog_id', ForeignKey(BlogMapped.Id), nullable=False)
    Source = Column('fk_source_id',
                    ForeignKey(SourceMapped.Id),
                    nullable=False)
    CId = Column('id_change', INTEGER(unsigned=True))
    LastActivity = Column('last_activity', DateTime)
    Auto = Column('auto', Boolean, nullable=False)
Esempio n. 5
0
class BlogThemeMapped(Base, BlogTheme):
    '''
    Provides the mapping for BlogTheme.
    '''
    __tablename__ = 'livedesk_blog_theme'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Name = Column('name', String(190), unique=True, nullable=False)
    URL = Column('url', String(1024), nullable=False)
Esempio n. 6
0
class ArticleFileMapped(Base, ArticleFile):
    '''
    Provides the mapping for ArticleFile.
    '''
    __tablename__ = 'article_file'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Article = Column('fk_article_id', ForeignKey(ArticleMapped.Id, ondelete='CASCADE'), nullable=False)
    MetaData = Column('fk_metadata_id', ForeignKey(MetaDataMapped.Id, ondelete='CASCADE'), nullable=False)
Esempio n. 7
0
class PostTypeMapped(Base, PostType):
    '''
    Provides the mapping for PostType.
    '''
    __tablename__ = 'post_type'
    __table_args__ = dict(mysql_engine='InnoDB')

    Key = Column('key', String(100), nullable=False, unique=True)
    # None REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 8
0
class RightTypeMapped(Base, RightType):
    '''
    Provides the mapping for RightType.
    '''
    __tablename__ = 'security_right_type'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Name = Column('name', String(100), nullable=False, unique=True)
    Description = Column('description', String(255))
Esempio n. 9
0
class VerificationStatusMapped(Base, VerificationStatus):
    '''
    Provides the mapping for PostType.
    '''
    __tablename__ = 'verification_status'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Key = Column('key', String(100), nullable=False, unique=True)
    # None REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 10
0
class ArticleMapped(Base, Article):
    '''
    Mapping for Article entity
    '''
    __tablename__ = 'article_demo'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')
    
    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    CreatedOn = Column('created_on', DateTime, nullable=False)
    Slug = Column('slug', String(255))
Esempio n. 11
0
class FilterMapped(Base, WithPath, WithSignature, Filter):
    '''
    Provides the ACL filter mapping.
    '''
    __tablename__ = 'acl_filter'
    __table_args__ = dict(mysql_engine='InnoDB')

    Name = Column('name', String(255), nullable=False, unique=True)
    Signature = WithSignature.createSignature()
    # Non REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 12
0
class RoleNode(Base):
    '''
    Provides the mapping for roles hierarchy.
    '''
    __tablename__ = 'rbac_role_node'
    __table_args__ = dict(mysql_engine='InnoDB')

    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    role = Column('fk_role_id', ForeignKey(RoleMapped.Id))
    left = Column('lft', INTEGER, nullable=False)
    right = Column('rgt', INTEGER, nullable=False)
class BlogCollaboratorTypeMapped(Base, BlogCollaboratorType):
    '''
    Provides the mapping for BlogCollaboratorType definition.
    '''
    __tablename__ = 'livedesk_collaborator_type'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Name = Column('name', String(190), nullable=False, unique=True)

    # Non REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 14
0
class GeneralSettingMapped(Base, GeneralSetting):
    '''
    Provides the mapping for PostType.
    '''
    __tablename__ = 'general_setting'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Key = Column('key', String(100), nullable=False, unique=True)
    Group = Column('group', String(100))
    Value = Column('value', String(100))
    # None REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 15
0
class PostMapped(Base, Post):
    '''
    Provides the mapping for Post.
    '''
    __tablename__ = 'post'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Uuid = Column('uuid', String(32))
    Type = association_proxy('type', 'Key')
    Creator = Column('fk_creator_id', ForeignKey(UserMapped.Id, ondelete='RESTRICT'), nullable=False)
    Author = Column('fk_author_id', ForeignKey(CollaboratorMapped.Id, ondelete='RESTRICT'))
    Feed = Column('fk_feed_id', ForeignKey(SourceMapped.Id, ondelete='RESTRICT'))
    Meta = Column('meta', TEXT)
    ContentPlain = Column('content_plain', TEXT)
    Content = Column('content', TEXT)
    CreatedOn = Column('created_on', DateTime, nullable=False)
    PublishedOn = Column('published_on', DateTime)
    WasPublished = Column('was_published', Boolean)
    UpdatedOn = Column('updated_on', DateTime)
    DeletedOn = Column('deleted_on', DateTime)
    @hybrid_property
    def IsModified(self):
        return self.UpdatedOn is not None
    @hybrid_property
    def IsPublished(self):
        return self.PublishedOn is not None
    @hybrid_property
    def AuthorName(self):
        if self.Author is None:
            if self.creator is None: return None
            else: return self.creator.Name
        return self.author.Name

    # Non REST model attributes --------------------------------------
    typeId = Column('fk_type_id', ForeignKey(PostTypeMapped.id, ondelete='RESTRICT'), nullable=False)
    type = relationship(PostTypeMapped, uselist=False, lazy='joined')
    author = relationship(CollaboratorMapped, uselist=False, lazy='joined')
    creator = relationship(UserMapped, uselist=False, lazy='joined')

    # Expression for hybrid ------------------------------------
    @classmethod
    @IsModified.expression
    def _IsModified(cls):
        return case([(cls.UpdatedOn != None, True)], else_=False)
    @classmethod
    @IsPublished.expression
    def _IsPublished(cls):
        return case([(cls.PublishedOn != None, True)], else_=False)
    @classmethod
    @AuthorName.expression
    def _AuthorName(cls):
        return case([(cls.Author == None, UserMapped.Name)], else_=CollaboratorMapped.Name)
Esempio n. 16
0
class PropertyMapped(Base, WithSignature, Property):
    '''
    Provides the ACL access property mapping.
    '''
    __tablename__ = 'acl_access_property'
    __table_args__ = (UniqueConstraint('fk_access_id', 'name', name='uix_acl_access_property'), dict(mysql_engine='InnoDB'))
    
    Name = Column('name', String(255))
    Signature = WithSignature.createSignature()
    # Non REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    accessId = Column('fk_access_id', ForeignKey(AccessMapped.Id, ondelete='CASCADE'), nullable=False)
Esempio n. 17
0
class BlogCollaboratorGroupMapped(Base, BlogCollaboratorGroup):
    '''
    Provides the mapping for BlogCollaboratorGroup definition.
    '''
    __tablename__ = 'livedesk_collaborator_group'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Blog = Column('fk_blog_id',
                  ForeignKey(BlogMapped.Id, ondelete='CASCADE'),
                  nullable=False)
    LastAccessOn = Column('last_access_on', DateTime, nullable=False)
Esempio n. 18
0
class AccessMapped(Base, WithPath, WithMethod, WithSignature, Access):
    '''
    Provides the ACL access mapping.
    '''
    __tablename__ = 'acl_access'
    __table_args__ = (UniqueConstraint('fk_path_id', 'fk_method_id', name='uix_acl_access'), dict(mysql_engine='InnoDB'))
    
    Id = Column('id', INTEGER(unsigned=True), autoincrement=False, primary_key=True)
    Priority = association_proxy('path', 'priority')
    Shadowing = Column('fk_shadowing_id', ForeignKey('acl_access.id', ondelete='CASCADE'))
    Shadowed = Column('fk_shadowed_id', ForeignKey('acl_access.id', ondelete='CASCADE'))
    Output = WithSignature.createSignature()
    Hash = Column('hash', String(50), nullable=False, unique=True)
Esempio n. 19
0
class BlogSeoMapped(Base, BlogSeo):
    '''
    Provides the mapping for BlogSeo definition.
    '''
    __tablename__ = 'livedesk_blog_seo'

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Blog = Column('fk_blog_id', ForeignKey(BlogMapped.Id), nullable=False)
    BlogTheme = Column('fk_theme_id',
                       ForeignKey(BlogThemeMapped.Id),
                       nullable=False)
    RefreshActive = Column('refresh_active', Boolean, nullable=False)
    RefreshInterval = Column('refresh_interval', INTEGER, nullable=False)
    MaxPosts = Column('max_posts', INTEGER)
    CallbackActive = Column('callback_active', Boolean, nullable=False)
    CallbackURL = Column('callback_url', String(512), nullable=True)
    NextSync = Column('next_sync', DateTime)
    LastCId = Column('last_cid', INTEGER(unsigned=True))
    HtmlURL = Column('html_url', String(512), nullable=True)
    LastSync = Column('last_sync', DateTime)
    CallbackStatus = Column('callback_status', String(512), nullable=True)
    ChangedOn = Column('changed_on', DateTime)
    LastBlocked = Column('last_blocked', DateTime)
Esempio n. 20
0
class RightMapped(Base, Right):
    '''
    Provides the mapping for Right.
    '''
    __tablename__ = 'security_right'
    __table_args__ = (UniqueConstraint('fk_right_type_id',
                                       'name',
                                       name='uix_type_name'),
                      dict(mysql_engine='InnoDB', mysql_charset='utf8'))

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Type = relationshipModel(RightTypeMapped.id)
    Name = Column('name', String(150), nullable=False)
    Description = Column('description', String(255))
Esempio n. 21
0
class SourceTypeMapped(Base, SourceType):
    '''
    Provides the mapping for SourceType.
    '''
    __tablename__ = 'source_type'
    __table_args__ = dict(mysql_engine='InnoDB')

    Key = Column('key', String(100), nullable=False, unique=True)
    # None REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)

    @reconstructor
    def init_on_load(self):
        self.Name = _(self.Key) # The translated name for the type
Esempio n. 22
0
class MetaInfoMapped(Base, MetaInfo):
    '''
    Provides the mapping for MetaData.
    '''
    __tablename__ = 'archive_meta_info'

    Id = Column('id', INTEGER(unsigned=True), primary_key=True, key='Id')
    MetaData = Column('fk_metadata_id', ForeignKey(MetaDataMapped.Id), nullable=False, key='MetaData')
    Language = Column('fk_language_id', ForeignKey(LanguageEntity.Id), nullable=False, key='Language')
    Title = Column('title', String(255), nullable=True, key='Title')
    Keywords = Column('keywords', String(255), nullable=True, key='Keywords')
    Description = Column('description', String(255), nullable=True, key='Description')

    __table_args__ = (UniqueConstraint(MetaData, Language), dict(mysql_engine='InnoDB', mysql_charset='utf8'))
Esempio n. 23
0
class ItemGroupMapped(Base, ItemGroup):
    '''
    Provides the mapping for ItemGroup.
    '''
    __tablename__ = 'item_group'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Item = Column('fk_item_id',
                  ForeignKey(ItemMapped.GUId, ondelete='CASCADE'),
                  nullable=False)
    LocalId = Column('local_id', String(100), nullable=False)
    Role = Column('role', String(255))
    Mode = Column('mode', String(255))
Esempio n. 24
0
class BlogPostDefinition:
    '''
    Provides the mapping for BlogCollaborator definition.
    '''
    __tablename__ = 'livedesk_post'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    CId = declared_attr(
        lambda cls: Column('id_change', INTEGER(unsigned=True)))
    Blog = declared_attr(lambda cls: Column(
        'fk_blog_id', ForeignKey(BlogMapped.Id), nullable=False))
    Order = declared_attr(lambda cls: Column('ordering', REAL))
    # Non REST model attribute --------------------------------------
    blogPostId = declared_attr(lambda cls: Column(
        'fk_post_id', ForeignKey(PostMapped.Id), primary_key=True))
Esempio n. 25
0
class GroupMapped(Base, Group):
    '''
    Provides the ACL group mapping.
    '''
    __tablename__ = 'acl_group'
    __table_args__ = dict(mysql_engine='InnoDB')

    Name = Column('name', String(255), nullable=False, unique=True)
    IsAnonymous = Column('is_anonymous',
                         Boolean,
                         nullable=False,
                         default=False)
    Description = Column('description', String(255))
    # Non REST model attribute --------------------------------------
    id = Column('id', INTEGER(unsigned=True), primary_key=True)
Esempio n. 26
0
class BlogSourceDB(Base):
    '''
    Provides the mapping for BlogSource.
    '''
    __tablename__ = 'livedesk_blog_source'
    __table_args__ = (UniqueConstraint('fk_blog',
                                       'fk_source',
                                       name='uix_blog_source'),
                      dict(mysql_engine='InnoDB', mysql_charset='utf8'))

    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    blog = Column('fk_blog', ForeignKey(BlogMapped.Id), nullable=False)
    source = Column('fk_source',
                    ForeignKey(SourceMapped.Id, ondelete='RESTRICT'),
                    nullable=False)
Esempio n. 27
0
class Ip_address(Base):
    __tablename__ = 'ip_addresses'
    ip_id = sa.Column(sa.Integer, primary_key=True)
    ip_address = sa.Column(INTEGER(display_width=11, unsigned=True))
    instances = relationship('Instance', backref='ip_address', lazy='dynamic')
    hosts = relationship('Host', backref='ip_address', lazy='dynamic')

    @property
    def true_ip(self):
        return session.query(sa.func.INET_NTOA(
            Ip_address.ip_address)).filter_by(ip_id=self.ip_id).first()[0]

    @true_ip.setter
    def true_ip(self, true_ip):
        self.ip_address = session.query(sa.func.INET_ATON(true_ip)).first()[0]
Esempio n. 28
0
class BlogCollaboratorGroupMemberMapped(Base, BlogCollaboratorGroupMember):
    '''
    Provides the mapping for BlogCollaboratorGroupMember definition.
    '''
    __tablename__ = 'livedesk_collaborator_group_member'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Group = Column('fk_group_id',
                   ForeignKey(BlogCollaboratorGroupMapped.Id,
                              ondelete='CASCADE'),
                   nullable=False)
    BlogCollaborator = Column('fk_collaborator_id',
                              ForeignKey(BlogCollaboratorMapped.Id,
                                         ondelete='CASCADE'),
                              nullable=False)
Esempio n. 29
0
class SourceMapped(Base, Source):
    '''
    Provides the mapping for Source.
    '''
    __tablename__ = 'source'
    __table_args__ = dict(mysql_engine='InnoDB', mysql_charset='utf8')

    Id = Column('id', INTEGER(unsigned=True), primary_key=True)
    Type = association_proxy('type', 'Key')
    Name = Column('name', String(255), nullable=False)
    URI = Column('uri', String(255), nullable=False)
    IsModifiable = Column('modifiable', Boolean, nullable=False)
    # Non REST model attribute --------------------------------------
    typeId = Column('fk_type_id',
                    ForeignKey(SourceTypeMapped.id, ondelete='RESTRICT'),
                    nullable=False)
    type = relationship(SourceTypeMapped, uselist=False, lazy='joined')
Esempio n. 30
0
class ThumbnailFormat(Base):
    '''
    Provides the mapping for thumbnails.
    This is not a REST model.
    '''
    __tablename__ = 'archive_thumbnail'
    __table_args__ = dict(mysql_engine='InnoDB')

    id = Column('id', INTEGER(unsigned=True), primary_key=True)
    format = Column('format',
                    String(190),
                    unique=True,
                    nullable=False,
                    doc='''
    The format for the reference of the thumbnail images in the media archive
    id = the meta data database id; name = the name of the content file; size = the key of the thumbnail size
    ''')