Exemplo n.º 1
0
def remove_alembic_version_table():
    """Remove alembic_version table."""
    if db.engine.dialect.has_table(db.engine, 'alembic_version'):
        alembic_version = db.Table('alembic_version',
                                   db.metadata,
                                   autoload_with=db.engine)
        alembic_version.drop(bind=db.engine)
Exemplo n.º 2
0
from elasticsearch_dsl import Q
from invenio_accounts.models import Role, User
from invenio_db import db
from invenio_records import Record

from invenio_explicit_acls.actors.mixins import RoleMixin

from ..models import Actor

roles_actors = db.Table(
    'explicit_acls_roles_roleactors',
    db.Column('role_id',
              db.Integer,
              db.ForeignKey('accounts_role.id'),
              primary_key=True),
    db.Column('actor_id',
              db.String(36),
              db.ForeignKey('explicit_acls_roleactor.id',
                            name='explicit_acls_ra1'),
              primary_key=True))


class RoleActor(RoleMixin, Actor):
    """An actor matching set of invenio roles."""

    __tablename__ = 'explicit_acls_roleactor'
    __mapper_args__ = {
        'polymorphic_identity': 'role',
    }
Exemplo n.º 3
0
"""Models for the HEPData Submission Workflow."""

import logging
import os

from invenio_accounts.models import User
from sqlalchemy import TypeDecorator, types, event
from invenio_db import db
from datetime import datetime

logging.basicConfig()
log = logging.getLogger(__name__)

data_reference_link = db.Table(
    'data_resource_link',
    db.Column('submission_id', db.Integer, db.ForeignKey('hepsubmission.id')),
    db.Column('dataresource_id', db.Integer,
              db.ForeignKey('dataresource.id', ondelete='CASCADE')))


class LargeBinaryString(TypeDecorator):
    """
    Decorator for unicode strings which are stored in the DB as LargeBinary objects,
    to allow them to be treated as strings in python3
    """
    impl = types.LargeBinary

    def process_literal_param(self, value, dialect):
        if isinstance(value, str):
            value = value.encode('utf-8', errors='replace')
Exemplo n.º 4
0
from flask import current_app, session
from flask_security import RoleMixin, UserMixin
from invenio_db import db
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import validates
from sqlalchemy_utils import IPAddressType, Timestamp

from .errors import AlreadyLinkedError

userrole = db.Table(
    'accounts_userrole',
    db.Column(
        'user_id', db.Integer(),
        db.ForeignKey('accounts_user.id',
                      name='fk_accounts_userrole_user_id')),
    db.Column(
        'role_id', db.Integer(),
        db.ForeignKey('accounts_role.id',
                      name='fk_accounts_userrole_role_id')),
)
"""Relationship between users and roles."""


class Role(db.Model, Timestamp, RoleMixin):
    """Role data model."""

    __tablename__ = "accounts_role"

    id = db.Column(db.Integer(), primary_key=True)
Exemplo n.º 5
0
#
# You should have received a copy of the GNU General Public License
# along with HEPData; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
"""HEPData Subscribers Model."""

from invenio_db import db

subscriber = db.Table(
    'subscriber',
    db.Column('publication_recid', db.Integer,
              db.ForeignKey('record_subscribers.publication_recid')),
    db.Column('user_id', db.Integer, db.ForeignKey('accounts_user.id')))


class Subscribers(db.Model):
    """
    WatchList is the main model for storing the query to be made for
    a watched query and the user who is watching it.
    """
    __tablename__ = "record_subscribers"
    publication_recid = db.Column(db.Integer, primary_key=True)

    subscribers = db.relationship("User",
                                  secondary="subscriber",
                                  cascade="all,delete")
Exemplo n.º 6
0
    "postgresql",
).with_variant(
    JSONType(),
    "sqlite",
).with_variant(
    JSONType(),
    "mysql",
))

userrole = db.Table(
    "accounts_userrole",
    db.Column(
        "user_id",
        db.Integer(),
        db.ForeignKey("accounts_user.id", name="fk_accounts_userrole_user_id"),
    ),
    db.Column(
        "role_id",
        db.Integer(),
        db.ForeignKey("accounts_role.id", name="fk_accounts_userrole_role_id"),
    ),
)
"""Relationship between users and roles."""


class Role(db.Model, Timestamp, RoleMixin):
    """Role data model."""

    __tablename__ = "accounts_role"

    id = db.Column(db.Integer(), primary_key=True)
Exemplo n.º 7
0
from oarepo_communities.proxies import current_oarepo_communities

_ = make_lazy_gettext(lambda: gettext)

OAREPO_COMMUNITIES_TYPES = [('wgroup', _('Working group')),
                            ('project', _('Project')),
                            ('rgroup', _('Research group')),
                            ('other', _('Other'))]
"""Community types or focus."""

oarepo_communities_role = db.Table(
    'oarepo_communities_role',
    db.Column(
        'community_id', db.String(63),
        db.ForeignKey('oarepo_communities.id',
                      name='fk_oarepo_communities_role_community_id')),
    db.Column('role_id',
              db.Integer(),
              db.ForeignKey('accounts_role.id',
                            name='fk_oarepo_communities_role_role_id'),
              unique=True),
)
"""Relationship between Communities and Invenio roles."""


class OARepoCommunityModel(db.Model, Timestamp):
    __tablename__ = 'oarepo_communities'
    __table_args__ = {'extend_existing': True}
    __versioned__ = {'versioning': False}

    id = db.Column(
        db.String(63),
Exemplo n.º 8
0
import uuid
from typing import List, Optional

from invenio_db import db
from invenio_pidstore.models import PersistentIdentifier
from invenio_rdm_records.models import BibliographicRecordDraft
from invenio_records import Record
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy_utils.types import UUIDType

from .signals import dataset_changed, dmp_changed

datamanagementplan_dataset = db.Table(
    "dmp_datamanagementplan_dataset",
    db.Column("dmp_id", UUIDType, db.ForeignKey("dmp_datamanagementplan.id")),
    db.Column("dataset_id", UUIDType, db.ForeignKey("dmp_dataset.id")),
)


class DataManagementPlan(db.Model):
    """Data Management Plan.

    Stores the external ID for the DMP, to enable querying for it in the
    DMP tool.
    """

    __tablename__ = "dmp_datamanagementplan"
    __versioned__ = {"versioning": False}

    id = db.Column(