def do_upgrade():
    """ Implement your upgrades here  """
    if not op.has_table('remoteACCOUNT'):
        op.create_table(
            'remoteACCOUNT',
            db.Column('id', db.Integer(display_width=15), nullable=False),
            db.Column('user_id', db.Integer(display_width=15), nullable=False),
            db.Column('client_id', db.String(length=255), nullable=False),
            db.Column('extra_data', db.JSON, nullable=True),
            db.ForeignKeyConstraint(['user_id'], ['user.id'], ),
            db.PrimaryKeyConstraint('id'),
            db.UniqueConstraint('user_id', 'client_id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteACCOUNT table skipped!'")

    if not op.has_table('remoteTOKEN'):
        op.create_table(
            'remoteTOKEN',
            db.Column('id_remote_account', db.Integer(display_width=15),
                    nullable=False),
            db.Column('token_type', db.String(length=40), nullable=False),
            db.Column('access_token', db.Text(), nullable=False),
            db.Column('secret', db.Text(), nullable=False),
            db.ForeignKeyConstraint(['id_remote_account'],
                                    ['remoteACCOUNT.id'], ),
            db.PrimaryKeyConstraint('id_remote_account', 'token_type'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteTOKEN' skipped!'")
Example #2
0
class NwsToolTip(db.Model):
    """Represents a NwsToolTip record."""
    __tablename__ = 'nwsTOOLTIP'
    id = db.Column(db.Integer(15, unsigned=True), nullable=False, primary_key=True,autoincrement=True)
    id_story = db.Column(db.Integer(15, unsigned=True), db.ForeignKey('nwsSTORY.id'))
    body = db.Column(db.String(512), nullable=False, server_default='0')
    target_element = db.Column(db.String(256), nullable=False,server_default='0')
    target_page = db.Column(db.String(256), nullable=False)


    @property
    def serialize(self):
       """Return object data in easily serializeable format"""
       return {
           'id'         : self.id,
           'id_story': self.id_story,
           'body': self.body,
           'target_element': self.target_element,
           'target_page': self.target_page

       }
    @property
    def serialize_many2many(self):
       """
       Return object's relations in easily serializeable format.
       NB! Calls many2many's serialize property.
       """
       return [ item.serialize for item in self.nwsSTORY]
Example #3
0
class CrcBORROWER(db.Model):
    """Represents a CrcBORROWER record."""
    def __init__(self):
        pass

    __tablename__ = 'crcBORROWER'
    id = db.Column(db.Integer(15, unsigned=True),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    ccid = db.Column(db.Integer(15, unsigned=True),
                     nullable=True,
                     unique=True,
                     server_default=None)
    name = db.Column(db.String(255),
                     nullable=False,
                     server_default='',
                     index=True)
    email = db.Column(db.String(255),
                      nullable=False,
                      server_default='',
                      index=True)
    phone = db.Column(db.String(60), nullable=True)
    address = db.Column(db.String(60), nullable=True)
    mailbox = db.Column(db.String(30), nullable=True)
    borrower_since = db.Column(db.DateTime,
                               nullable=False,
                               server_default='1900-01-01 00:00:00')
    borrower_until = db.Column(db.DateTime,
                               nullable=False,
                               server_default='1900-01-01 00:00:00')
    notes = db.Column(db.Text, nullable=True)
Example #4
0
class LnkENTRY(db.Model):
    """Represents a LnkENTRY record."""
    __tablename__ = 'lnkENTRY'

    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   nullable=False)
    origin_url = db.Column(db.String(100), nullable=False)
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False)
    additional_properties = db.Column(db.Binary)
    type = db.Column(db.String(30), nullable=False, index=True)
    status = db.Column(db.String(30),
                       nullable=False,
                       server_default='PENDING',
                       index=True)
    insert_time = db.Column(db.DateTime,
                            server_default='1900-01-01 00:00:00',
                            index=True)

    @property
    def title(self):
        try:
            return db.object_session(self).query(LnkENTRYURLTITLE).\
                filter(db.and_(
                    LnkENTRYURLTITLE.url==self.origin_url,
                    LnkENTRYURLTITLE.title<>"",
                    LnkENTRYURLTITLE.broken==0)).first().title
        except:
            return self.origin_url
Example #5
0
class Bibdocfsinfo(db.Model):
    """Represents a Bibdocfsinfo record."""
    __tablename__ = 'bibdocfsinfo'

    id_bibdoc = db.Column(db.MediumInteger(9, unsigned=True),
                          db.ForeignKey(Bibdoc.id),
                          primary_key=True,
                          nullable=False,
                          autoincrement=False)
    version = db.Column(db.TinyInteger(4, unsigned=True),
                        primary_key=True,
                        nullable=False,
                        autoincrement=False)
    format = db.Column(db.String(50),
                       primary_key=True,
                       nullable=False,
                       index=True)
    last_version = db.Column(db.Boolean, nullable=False, index=True)
    cd = db.Column(db.DateTime, nullable=False, index=True)
    md = db.Column(db.DateTime, nullable=False, index=True)
    checksum = db.Column(db.Char(32), nullable=False)
    filesize = db.Column(db.BigInteger(15, unsigned=True),
                         nullable=False,
                         index=True)
    mime = db.Column(db.String(100), nullable=False, index=True)
    master_format = db.Column(db.String(50))
Example #6
0
class nwsTOOLTIP(db.Model):
    """
    CREATE TABLE 'nwsTOOLTIP' (
     'id' int(11) NOT NULL AUTO_INCREMENT,
     'id_story' int(11) NOT NULL,
     'body' varchar(512) NOT NULL,
     'target_element' varchar(256) NOT NULL DEFAULT '',
     'target_page' varchar(256) NOT NULL DEFAULT '',
     PRIMARY KEY ('id'),
     KEY 'id_story' ('id_story'),
     CONSTRAINT 'nwsTOOLTIP_ibfk_1' FOREIGN KEY ('id_story') REFERENCES 'nwsSTORY' ('id')
    );
    """
    __tablename__ = 'nwsTOOLTIP'

    id = db.Column(db.Integer(11),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    id_story = db.Column(db.Integer(11), db.ForeignKey(nwsSTORY.id))
    body = db.Column(db.String(512), nullable=False)
    target_element = db.Column(db.String(256), nullable=False, default='')
    target_page = db.Column(db.String(256), nullable=False, default='')

    idstory = db.relationship('nwsSTORY', foreign_keys='nwsTOOLTIP.id_story')
Example #7
0
class CrcPURCHASE(db.Model):
    """Represents a CrcPURCHASE record."""
    def __init__(self):
        pass

    __tablename__ = 'crcPURCHASE'
    id = db.Column(db.Integer(15, unsigned=True),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False,
                          server_default='0')
    id_crcVENDOR = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(CrcVENDOR.id),
                             nullable=False,
                             server_default='0')
    ordered_date = db.Column(db.DateTime,
                             nullable=False,
                             server_default='1900-01-01 00:00:00')
    expected_date = db.Column(db.DateTime,
                              nullable=False,
                              server_default='1900-01-01 00:00:00')
    price = db.Column(db.String(20), nullable=False, server_default='0')
    status = db.Column(db.String(20), nullable=False, server_default='')
    notes = db.Column(db.Text, nullable=True)
    bibrec = db.relationship(Bibrec, backref='purchases')
    vendor = db.relationship(CrcVENDOR, backref='purchases')
Example #8
0
class BibdocBibdoc(db.Model):
    """Represent a BibdocBibdoc record."""

    __tablename__ = 'bibdoc_bibdoc'
    id = db.Column(db.MediumInteger(9, unsigned=True),
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    id_bibdoc1 = db.Column(db.MediumInteger(9, unsigned=True),
                           db.ForeignKey(Bibdoc.id),
                           nullable=True)
    version1 = db.Column(db.TinyInteger(4, unsigned=True))
    format1 = db.Column(db.String(50))
    id_bibdoc2 = db.Column(db.MediumInteger(9, unsigned=True),
                           db.ForeignKey(Bibdoc.id),
                           nullable=True)
    version2 = db.Column(db.TinyInteger(4, unsigned=True))
    format2 = db.Column(db.String(50))
    rel_type = db.Column(db.String(255), nullable=True)
    bibdoc1 = db.relationship(Bibdoc,
                              backref='bibdoc2s',
                              primaryjoin=Bibdoc.id == id_bibdoc1)
    bibdoc2 = db.relationship(Bibdoc,
                              backref='bibdoc1s',
                              primaryjoin=Bibdoc.id == id_bibdoc2)
Example #9
0
class HstDOCUMENT(db.Model):
    """Represent a HstDOCUMENT record."""

    __tablename__ = 'hstDOCUMENT'
    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    id_bibdoc = db.Column(db.MediumInteger(9, unsigned=True),
                          db.ForeignKey(Bibdoc.id),
                          primary_key=True,
                          nullable=False,
                          autoincrement=False)
    docname = db.Column(db.String(250), nullable=False, index=True)
    docformat = db.Column(db.String(50), nullable=False, index=True)
    docversion = db.Column(db.TinyInteger(4, unsigned=True), nullable=False)
    docsize = db.Column(db.BigInteger(15, unsigned=True), nullable=False)
    docchecksum = db.Column(db.Char(32), nullable=False)
    doctimestamp = db.Column(db.DateTime, nullable=False, index=True)
    action = db.Column(db.String(50), nullable=False, index=True)
    job_id = db.Column(db.MediumInteger(15, unsigned=True),
                       nullable=True,
                       index=True)
    job_name = db.Column(db.String(255), nullable=True, index=True)
    job_person = db.Column(db.String(255), nullable=True, index=True)
    job_date = db.Column(db.DateTime, nullable=True, index=True)
    job_details = db.Column(db.iBinary, nullable=True)
Example #10
0
class Bibdoc(db.Model):
    """Represent a Bibdoc record."""

    __tablename__ = 'bibdoc'
    id = db.Column(db.MediumInteger(9, unsigned=True),
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    status = db.Column(db.Text, nullable=False)
    docname = db.Column(
        db.String(250),
        nullable=True,  # collation='utf8_bin'
        index=True)
    creation_date = db.Column(db.DateTime,
                              nullable=False,
                              server_default='1900-01-01 00:00:00',
                              index=True)
    modification_date = db.Column(db.DateTime,
                                  nullable=False,
                                  server_default='1900-01-01 00:00:00',
                                  index=True)
    text_extraction_date = db.Column(db.DateTime,
                                     nullable=False,
                                     server_default='1900-01-01 00:00:00')
    doctype = db.Column(db.String(255))
Example #11
0
class IdxINDEXField(db.Model):
    """Represent a IdxINDEXField record."""

    __tablename__ = 'idxINDEX_field'
    id_idxINDEX = db.Column(db.MediumInteger(9, unsigned=True),
                            db.ForeignKey(IdxINDEX.id),
                            primary_key=True)
    id_field = db.Column(db.MediumInteger(9, unsigned=True),
                         db.ForeignKey(Field.id),
                         primary_key=True)
    regexp_punctuation = db.Column(db.String(255),
                                   nullable=False,
                                   server_default='[.,:;?!"]')
    regexp_alphanumeric_separators = db.Column(db.String(255),
                                               nullable=False)  # FIX ME ,
    # server_default='[!"#$\\%&''()*+,-./:;<=>?@[\\]^\\_`{|}~]')
    idxINDEX = db.relationship(IdxINDEX,
                               backref='fields',
                               lazy='joined',
                               innerjoin=True)
    field = db.relationship(Field,
                            backref='idxINDEXes',
                            lazy='joined',
                            innerjoin=True)

    @classmethod
    def get_field_tokenizers(cls):
        """Get field tokenizers."""
        return db.session.query(Field.name, IdxINDEX.tokenizer).all()
Example #12
0
class Bibfmt(db.Model):
    """Represent a Bibfmt record."""

    __tablename__ = 'bibfmt'

    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False,
                          server_default='0',
                          primary_key=True,
                          autoincrement=False)

    format = db.Column(db.String(10),
                       nullable=False,
                       server_default='',
                       primary_key=True,
                       index=True)

    kind = db.Column(db.String(10),
                     nullable=False,
                     server_default='',
                     index=True)

    last_updated = db.Column(db.DateTime,
                             nullable=False,
                             server_default='1900-01-01 00:00:00',
                             index=True)

    value = db.Column(db.iLargeBinary)

    needs_2nd_pass = db.Column(db.TinyInteger(1), server_default='0')

    bibrec = db.relationship(Bibrec, backref='bibfmt')
Example #13
0
class SbmFUNDESC(db.Model):
    """Represents a SbmFUNDESC record."""
    __tablename__ = 'sbmFUNDESC'
    function = db.Column(db.String(40),
                         nullable=False,
                         server_default='',
                         primary_key=True)
    param = db.Column(db.String(40), primary_key=True)
Example #14
0
class LnkADMINURL(db.Model):
    """Represents a LnkADMINURL record."""
    __tablename__ = 'lnkADMINURL'

    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   nullable=False)
    url = db.Column(db.String(100), nullable=False, unique=True)
    list = db.Column(db.String(30), nullable=False, index=True)
Example #15
0
class OaiREPOSITORY(db.Model):
    """Represents a OaiREPOSITORY record."""

    __tablename__ = 'oaiREPOSITORY'
    id = db.Column(db.MediumInteger(9, unsigned=True),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    setName = db.Column(db.String(255), nullable=False, server_default='')
    setSpec = db.Column(db.String(255), nullable=False, server_default='')
    setCollection = db.Column(db.String(255),
                              nullable=False,
                              server_default='')
    setDescription = db.Column(db.Text, nullable=False)
    setDefinition = db.Column(db.Text, nullable=False)
    setRecList = db.Column(db.iLargeBinary, nullable=True)
    last_updated = db.Column(db.DateTime,
                             nullable=False,
                             server_default='1970-01-01 00:00:00')
    p1 = db.Column(db.Text, nullable=False, default='')
    f1 = db.Column(db.Text, nullable=False, default='')
    m1 = db.Column(db.Text, nullable=False, default='')
    p2 = db.Column(db.Text, nullable=False, default='')
    f2 = db.Column(db.Text, nullable=False, default='')
    m2 = db.Column(db.Text, nullable=False, default='')
    p3 = db.Column(db.Text, nullable=False, default='')
    f3 = db.Column(db.Text, nullable=False, default='')
    m3 = db.Column(db.Text, nullable=False, default='')

    @classmethod
    def update_setdefinition_listener(cls, mapper, connection, target):
        """Update setDefinition attribute on before_insert/before_update events."""
        # FIXME: Next two lines
        op1 = ''
        op2 = ''

        # Set fields to empty string if none.
        for attr in [
                'p1', 'f1', 'm1', 'p2', 'f2', 'm2', 'p3', 'f3', 'm3',
                'setCollection', 'setName', 'setSpec', 'setDescription'
        ]:
            if getattr(target, attr) is None:
                setattr(target, attr, '')

        target.setDefinition = \
            'c=' + target.setCollection + ';' + \
            'p1=' + target.p1 + ';' + \
            'f1=' + target.f1 + ';' + \
            'm1=' + target.m1 + ';' + \
            'op1=' + op1 + ';' + \
            'p2=' + target.p2 + ';' + \
            'f2=' + target.f2 + ';' + \
            'm2=' + target.m2 + ';' + \
            'op2=' + op2 + ';' + \
            'p3=' + target.p3 + ';' + \
            'f3=' + target.f3 + ';' + \
            'm3=' + target.m3 + ';'
Example #16
0
class WapCACHE(db.Model):
    """Represents a WapCACHE record."""
    __tablename__ = 'wapCACHE'

    object_name = db.Column(db.String(120), primary_key=True, nullable=False)
    object_key = db.Column(db.String(120), primary_key=True, nullable=False)
    object_value = db.Column(db.Text)  #FIXME LongText
    object_status = db.Column(db.String(120), index=True)
    last_updated = db.Column(db.DateTime, nullable=False, index=True)
Example #17
0
class SbmREFEREES(db.Model):
    """Represents a SbmREFEREES record."""
    __tablename__ = 'sbmREFEREES'
    doctype = db.Column(db.String(10), nullable=False, server_default='')
    categ = db.Column(db.String(10), nullable=False, server_default='')
    name = db.Column(db.String(50), nullable=False, server_default='')
    address = db.Column(db.String(50), nullable=False, server_default='')
    rid = db.Column(db.Integer(11),
                    nullable=False,
                    primary_key=True,
                    autoincrement=True)
Example #18
0
class SbmPUBLICATIONDATA(db.Model):
    """Represents a SbmPUBLICATIONDATA record."""
    __tablename__ = 'sbmPUBLICATIONDATA'
    doctype = db.Column(db.String(10),
                        nullable=False,
                        server_default='',
                        primary_key=True)
    editoboard = db.Column(db.String(250), nullable=False, server_default='')
    base = db.Column(db.String(10), nullable=False, server_default='')
    logicalbase = db.Column(db.String(10), nullable=False, server_default='')
    spokesperson = db.Column(db.String(50), nullable=False, server_default='')
Example #19
0
class BsrMETHOD(db.Model):

    """Represent a BsrMETHOD record."""

    __tablename__ = 'bsrMETHOD'

    id = db.Column(db.MediumInteger(9, unsigned=True),
                   primary_key=True, nullable=False)
    name = db.Column(db.String(20), nullable=False, unique=True)
    definition = db.Column(db.String(255), nullable=False)
    washer = db.Column(db.String(255), nullable=False)

    bucket_data = association_proxy('buckets', 'data')

    def get_name_ln(self, ln=None):
        """Return localized method name."""
        try:
            if ln is None:
                ln = g.ln
            return self.names.filter_by(ln=g.ln, type='ln').one().value
        except:
            return self.name

    @classmethod
    def get_sorting_methods(cls):
        """Return initialized method mapping."""
        return dict(db.session.query(cls.name, cls.definition).filter(
            db.session.query(BsrMETHODDATA).filter(
                BsrMETHODDATA.id_bsrMETHOD == cls.id
            ).exists()
        ).all())

    def get_cache(self):
        """Return data to populate cache."""
        if len(self.methoddata) < 1:
            return {}
        return dict(
            data_dict_ordered=self.methoddata[0].ordered,
            bucket_data=dict(self.bucket_data),
        )

    @classmethod
    def timestamp_verifier(cls, name):
        """Return last modification time for given sorting method."""
        min_date = datetime(1970, 1, 1)
        method_id = db.select([cls.id], cls.name == name)
        data_updated = db.session.query(
            db.func.max(BsrMETHODDATA.last_updated)
        ).filter(BsrMETHODDATA.id_bsrMETHOD.in_(method_id)).scalar()
        bucket_updated = db.session.query(
            db.func.max(BsrMETHODDATABUCKET.last_updated)
        ).filter(BsrMETHODDATABUCKET.id_bsrMETHOD.in_(method_id)).scalar()
        return max(data_updated, bucket_updated, min_date)
Example #20
0
class JrnISSUE(db.Model):
    """Represents a JrnISSUE record."""
    __tablename__ = 'jrnISSUE'
    id_jrnJOURNAL = db.Column(db.MediumInteger(9, unsigned=True),
                db.ForeignKey(JrnJOURNAL.id), nullable=False,
                primary_key=True)
    issue_number = db.Column(db.String(50), nullable=False, server_default='',
                primary_key=True)
    issue_display = db.Column(db.String(50), nullable=False, server_default='')
    date_released = db.Column(db.DateTime, nullable=True)
    date_announced = db.Column(db.DateTime, nullable=True)
    journal = db.relationship(JrnJOURNAL, backref='issues')
Example #21
0
class SbmPARAMETERS(db.Model):
    """Represents a SbmPARAMETERS record."""
    __tablename__ = 'sbmPARAMETERS'
    doctype = db.Column(db.String(10),
                        nullable=False,
                        server_default='',
                        primary_key=True)
    name = db.Column(db.String(40),
                     nullable=False,
                     server_default='',
                     primary_key=True)
    value = db.Column(db.Text, nullable=False)
Example #22
0
class AccARGUMENT(db.Model):
    """Represent an authorization argument."""

    __tablename__ = 'accARGUMENT'
    id = db.Column(db.Integer(15), primary_key=True, autoincrement=True)
    keyword = db.Column(db.String(32), nullable=True)
    value = db.Column(db.String(255), nullable=True)
    __table_args__ = (db.Index('KEYVAL', keyword,
                               value), db.Model.__table_args__)

    def __repr__(self):
        return "{0.keyword}={0.value}".format(self)
Example #23
0
def do_upgrade():
    """Upgrade recipe.

    Adds two new columns (password_salt and password_scheme) and migrates
    emails to password salt.
    """
    op.add_column(
        'user', db.Column('password_salt',
                          db.String(length=255),
                          nullable=True))
    op.add_column(
        'user',
        db.Column('password_scheme', db.String(length=50), nullable=False))

    # Temporary column needed for data migration
    op.add_column('user', db.Column('new_password', db.String(length=255)))

    # Migrate emails to password_salt
    m = db.MetaData(bind=db.engine)
    m.reflect()
    u = m.tables['user']

    conn = db.engine.connect()
    conn.execute(
        u.update().values(password_salt=u.c.email,
                          password_scheme='invenio_aes_encrypted_email'))

    # Migrate password blob to password varchar.
    for row in conn.execute(select([u])):
        # NOTE: Empty string passwords were stored as empty strings
        # instead of a hashed version, hence they must be treated differently.
        legacy_pw = row[u.c.password] or mysql_aes_encrypt(row[u.c.email], "")

        stmt = u.update().where(u.c.id == row[u.c.id]).values(
            new_password=hashlib.sha256(legacy_pw).hexdigest())
        conn.execute(stmt)

    # Create index
    op.create_index(op.f('ix_user_password_scheme'),
                    'user', ['password_scheme'],
                    unique=False)

    # Drop old database column and rename new.
    op.drop_column('user', 'password')
    op.alter_column(
        'user',
        'new_password',
        new_column_name='password',
        existing_type=mysql.VARCHAR(255),
        existing_nullable=True,
    )
Example #24
0
class AccROLE(db.Model):

    """Represent an access role."""

    __tablename__ = 'accROLE'
    id = db.Column(db.Integer(15, unsigned=True), primary_key=True,
                   autoincrement=True)
    name = db.Column(db.String(32), unique=True, nullable=True)
    description = db.Column(db.String(255), nullable=True)
    firerole_def_ser = db.Column(db.iBinary, nullable=True)
    firerole_def_src = db.Column(db.Text, nullable=True)

    def __repr__(self):
        return "{0.name} - {0.description}".format(self)
Example #25
0
class NwsSTORY(db.Model):
    """Represents a nwsSTORY record."""
    __tablename__ = 'nwsSTORY'
    id = db.Column(db.Integer(11, unsigned=True), nullable=False, primary_key=True,autoincrement=True)
    title = db.Column(db.String(256), nullable=False, default='')
    body = db.Column(db.Text, nullable=False, default='')
    created = db.Column(db.TIMESTAMP, nullable=False)
    document_status=db.Column(db.String(45), nullable=False, default='SHOW')
    remote_ip=db.Column(db.String(100), nullable=False, default='0.0.0.0')
    email=db.Column(db.String(100), nullable=False, default='*****@*****.**')
    nickname=db.Column(db.String(100), nullable=False, default='admin')
    uid=db.Column(db.Integer(11, unsigned=True), nullable=False)
    nwsToolTip = db.relationship('NwsToolTip', backref='nwsSTORY',cascade='all, delete, delete-orphan')
    nwsTAG = db.relationship('NwsTAG', backref='nwsSTORY',cascade='all, delete, delete-orphan')
Example #26
0
class Field(db.Model):
    """Represent a Field record."""
    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, self.id)

    __tablename__ = 'field'
    id = db.Column(db.MediumInteger(9, unsigned=True), primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    code = db.Column(db.String(255), unique=True, nullable=False)

    @property
    def name_ln(self):
        from invenio.legacy.search_engine import get_field_i18nname
        return get_field_i18nname(self.name, g.ln)
Example #27
0
class LnkENTRYURLTITLE(db.Model):
    """Represents a LnkENTRYURLTITLE record."""
    __tablename__ = 'lnkENTRYURLTITLE'

    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   nullable=False)
    url = db.Column(db.String(100), nullable=False, unique=True)
    title = db.Column(db.String(100), nullable=False, index=True)
    manual_set = db.Column(db.TinyInteger(1),
                           nullable=False,
                           server_default='0')
    broken_count = db.Column(db.Integer(5), server_default='0')
    broken = db.Column(db.TinyInteger(1), nullable=False, server_default='0')
Example #28
0
class AccACTION(db.Model):

    """Represent an access action."""

    __tablename__ = 'accACTION'
    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True, autoincrement=True)
    name = db.Column(db.String(32), unique=True, nullable=True)
    description = db.Column(db.String(255), nullable=True)
    allowedkeywords = db.Column(db.String(255), nullable=True)
    optional = db.Column(db.Enum('yes', 'no', name='yes_no'), nullable=False,
                         server_default='no')

    def __repr__(self):
        return "{0.name}".format(self)
Example #29
0
class BsrMETHODNAME(db.Model):

    """Represent a BsrMETHODNAME record."""

    __tablename__ = 'bsrMETHODNAME'

    id_bsrMETHOD = db.Column(db.MediumInteger(9, unsigned=True),
                             db.ForeignKey(BsrMETHOD.id),
                             primary_key=True, nullable=False,
                             autoincrement=False)
    ln = db.Column(db.String(5), primary_key=True, nullable=False)
    type = db.Column(db.String(3), primary_key=True, nullable=False)
    value = db.Column(db.String(255), nullable=False)
    method = db.relationship(BsrMETHOD, backref=db.backref('names',
                                                           lazy='dynamic'))
Example #30
0
class NwsToolTip(db.Model):
    """Represents a NwsToolTip record."""
    __tablename__ = 'nwsTOOLTIP'
    id = db.Column(db.Integer(15, unsigned=True),
                   nullable=False,
                   server_default='0',
                   primary_key=True,
                   autoincrement=True)
    id_story = db.Column(db.Integer(15, unsigned=True),
                         db.ForeignKey('nwsSTORY.id'))
    body = db.Column(db.String(512), nullable=False, server_default='0')
    target_element = db.Column(db.String(256),
                               nullable=False,
                               server_default='0')
    target_page = db.Column(db.String(256), nullable=False)