Skip to content

Commit

Permalink
Merge 3225485 into 5cac804
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinaStoikou committed Nov 24, 2020
2 parents 5cac804 + 3225485 commit ec75ffb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
17 changes: 15 additions & 2 deletions invenio_app_ils/cli.py
Expand Up @@ -32,6 +32,8 @@
from invenio_userprofiles.models import UserProfile
from lorem.text import TextLorem

from invenio_app_ils.errors import RecordRelationsError

from .acquisition.api import ORDER_PID_TYPE, VENDOR_PID_TYPE, Order, Vendor
from .document_requests.api import DOCUMENT_REQUEST_PID_TYPE, DocumentRequest
from .documents.api import DOCUMENT_PID_TYPE, Document
Expand Down Expand Up @@ -876,8 +878,19 @@ def add_random_relations(relation_type):
documents, randint(2, min(5, len(documents)))
)

objs.append(random_docs[0])
for record in random_docs[1:]:
for record in random_docs:
for doc in documents:
try:
rr.add(
doc, record, relation_type=relation_type
)
break
except RecordRelationsError:
continue
objs.append(record)

if relation_type.name == "edition":
record = self.random_series(series, "MULTIPART_MONOGRAPH")
rr.add(random_docs[0], record, relation_type=relation_type)
objs.append(record)

Expand Down
4 changes: 2 additions & 2 deletions invenio_app_ils/eitems/loaders/jsonschemas/eitems.py
Expand Up @@ -12,8 +12,8 @@

from invenio_app_ils.documents.loaders.jsonschemas.document import \
IdentifierSchema
from invenio_app_ils.records.loaders.schemas.changed_by import ChangedBySchema, \
set_changed_by
from invenio_app_ils.records.loaders.schemas.changed_by import (
ChangedBySchema, set_changed_by)


class URLSchema(Schema):
Expand Down
Expand Up @@ -12,9 +12,8 @@

from invenio_app_ils.internal_locations.api import InternalLocation
from invenio_app_ils.locations.api import Location
from invenio_app_ils.records.jsonresolvers.api import (
get_field_value_for_record as get_field_value,
)
from invenio_app_ils.records.jsonresolvers.api import \
get_field_value_for_record as get_field_value
from invenio_app_ils.records.jsonresolvers.api import get_pid_or_default, pick

# Note: there must be only one resolver per file,
Expand Down
6 changes: 3 additions & 3 deletions invenio_app_ils/items/loaders/jsonschemas/items.py
Expand Up @@ -8,11 +8,11 @@
"""Items schema for marshmallow loader."""

from invenio_records_rest.schemas import RecordMetadataSchemaJSONV1
from marshmallow import EXCLUDE, Schema, fields, validate, pre_load
from marshmallow import EXCLUDE, Schema, fields, pre_load, validate

from invenio_app_ils.items.api import Item
from invenio_app_ils.records.loaders.schemas.changed_by import \
ChangedBySchema, set_changed_by
from invenio_app_ils.records.loaders.schemas.changed_by import (
ChangedBySchema, set_changed_by)
from invenio_app_ils.records.loaders.schemas.price import PriceSchema


Expand Down

0 comments on commit ec75ffb

Please sign in to comment.