Exemplo n.º 1
0
from invenio.base.i18n import _, gettext_set_language
from invenio.ext.sqlalchemy import db
from invenio.ext.sqlalchemy.utils import attribute_multi_dict_collection
from invenio.modules.formatter.registry import output_formats
from invenio.modules.search.models import Field, Fieldvalue

from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.schema import Index

from werkzeug.utils import cached_property

external_collection_mapper = attribute_multi_dict_collection(
    creator=lambda k, v: CollectionExternalcollection(type=k,
                                                      externalcollection=v),
    key_attr=lambda obj: obj.type,
    val_attr=lambda obj: obj.externalcollection)


class Collection(db.Model):
    """Represent a Collection record."""
    def __repr__(self):
        """Return class representation."""
        return 'Collection <id: {0.id}, name: {0.name}, dbquery: {0.query}, ' \
               'nbrecs: {0.nbrecs}>'.format(self)

    def __unicode__(self):
        """Unicode."""
        suffix = ' ({0})'.format(_('default')) if self.id == 1 else ''
        return u"{0.id}. {0.name}{1}".format(self, suffix)
Exemplo n.º 2
0
from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.schema import Index
from werkzeug.utils import cached_property

from invenio.base.globals import cfg
from invenio.base.i18n import _, gettext_set_language
from invenio.ext.sqlalchemy import db
from invenio.ext.sqlalchemy.utils import attribute_multi_dict_collection
from invenio_formatter.registry import output_formats
from invenio_search.models import Field, Fieldvalue


external_collection_mapper = attribute_multi_dict_collection(
    creator=lambda k, v: CollectionExternalcollection(type=k,
                                                      externalcollection=v),
    key_attr=lambda obj: obj.type,
    val_attr=lambda obj: obj.externalcollection)


class Collection(db.Model):

    """Represent a Collection record."""

    def __repr__(self):
        """Return class representation."""
        return 'Collection <id: {0.id}, name: {0.name}, dbquery: {0.query}, ' \
               'nbrecs: {0.nbrecs}>'.format(self)

    def __unicode__(self):
        """Unicode."""