コード例 #1
0
def create_eitem(document_pid, open_access=True):
    """Create eitem record."""
    obj = {
        "document_pid": document_pid,
        "open_access": open_access,
        "created_by": {
            "type": "script",
            "value": "migration"
        },
    }
    record_uuid = uuid.uuid4()
    provider = EItemIdProvider.create(
        object_type="rec",
        object_uuid=record_uuid,
    )

    obj["pid"] = provider.pid.pid_value
    eitem = EItem.create(obj, record_uuid)
    eitems_logger.info(
        "CREATED",
        extra=dict(
            document_pid=document_pid,
            new_pid=eitem["pid"],
            status="SUCCESS",
        ),
    )
    return eitem
コード例 #2
0
def create_eitem(document_pid, open_access=True):
    """Create eitem record."""
    obj = {"document_pid": document_pid, "open_access": open_access}
    record_uuid = uuid.uuid4()
    provider = EItemIdProvider.create(
        object_type="rec",
        object_uuid=record_uuid,
    )

    obj["pid"] = provider.pid.pid_value
    eitem = EItem.create(obj, record_uuid)
    return eitem
コード例 #3
0
def test_eitem_refs(app, testdata):
    """Test creation of an eitem."""
    eitem = EItem.create(
        dict(
            pid="eitemid-99",
            document_pid="docid-1",
            created_by=dict(type="script", value="demo"),
        ))
    assert "$schema" in eitem
    assert "document" in eitem and "$ref" in eitem["document"]

    eitem = EItem.get_record_by_pid("eitemid-4")
    eitem = eitem.replace_refs()
    assert "document" in eitem and eitem["document"]["title"]
コード例 #4
0
ファイル: api.py プロジェクト: kprzerwa/cds-ils
def create_eitem(document_pid, open_access=True):
    """Create eitem record."""
    obj = {
        "document_pid": document_pid,
        "open_access": open_access,
        "created_by": {
            "type": "script",
            "value": "migration"
        },
    }
    record_uuid = uuid.uuid4()
    provider = EItemIdProvider.create(
        object_type="rec",
        object_uuid=record_uuid,
    )

    obj["pid"] = provider.pid.pid_value
    eitem = EItem.create(obj, record_uuid)
    return eitem