diff --git a/poetry.lock b/poetry.lock index 69bb7a3e3e..8b55322edb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -457,7 +457,7 @@ description = "A robust email syntax and deliverability validation library for P name = "email-validator" optional = false python-versions = "*" -version = "1.1.0" +version = "1.1.1" [package.dependencies] dnspython = ">=1.15.0" @@ -1837,7 +1837,7 @@ description = "Extract, clean, transform, hyphenate and metadata for ISBNs (Inte name = "isbnlib" optional = false python-versions = "*" -version = "3.10.0" +version = "3.10.1" [[package]] category = "dev" @@ -1910,7 +1910,7 @@ version = "1.25" jsonpointer = ">=1.9" [[package]] -category = "dev" +category = "main" description = "Python library for serializing any arbitrary object graph into JSON" name = "jsonpickle" optional = false @@ -2143,7 +2143,7 @@ description = "More routines for operating on iterables, beyond itertools" name = "more-itertools" optional = false python-versions = ">=3.5" -version = "8.2.0" +version = "8.3.0" [[package]] category = "main" @@ -2187,7 +2187,7 @@ description = "Core utilities for Python packages" name = "packaging" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "20.3" +version = "20.4" [package.dependencies] pyparsing = ">=2.0.2" @@ -2667,7 +2667,7 @@ description = "Python client for Redis key-value store" name = "redis" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "3.5.1" +version = "3.5.2" [package.extras] hiredis = ["hiredis (>=0.1.3)"] @@ -2686,7 +2686,7 @@ description = "Alternative regular expression module, to replace re." name = "regex" optional = false python-versions = "*" -version = "2020.5.13" +version = "2020.5.14" [[package]] category = "main" @@ -2787,7 +2787,7 @@ description = "A lightweight OAI client library for Python" name = "sickle" optional = false python-versions = "*" -version = "0.6.5" +version = "0.7.0" [package.dependencies] lxml = ">=3.2.3" @@ -3268,6 +3268,7 @@ version = "0.12.0" [[package]] category = "main" description = "Backport of pathlib-compatible object wrapper for zip files" +marker = "python_version < \"3.8\" or python_version >= \"3.7\" and python_version < \"3.8\"" name = "zipp" optional = false python-versions = ">=3.6" @@ -3278,7 +3279,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "389bd2e1de6f1b8e79a30c8e95f792a85aea7d0efd47337da97395dd291514d6" +content-hash = "a8519bd86c9f3736490a8422e3b1661ac4f42a137aad201b9b09fb275ce40a58" python-versions = ">= 3.6, < 3.8" [metadata.files] @@ -3494,8 +3495,8 @@ elasticsearch-dsl = [ {file = "elasticsearch_dsl-6.1.0-py2.py3-none-any.whl", hash = "sha256:d6d974cd2289543a3350690494a43fe9996485b8dc6f1d8758cb56bee01244bd"}, ] email-validator = [ - {file = "email_validator-1.1.0-py2.py3-none-any.whl", hash = "sha256:de2aad89b13574a73fd26c04a5200389b293bd9578602fc3b51537ada47af153"}, - {file = "email_validator-1.1.0.tar.gz", hash = "sha256:2d515ed56eca41a2c91bbe1e0b1054d604a2502417487b553d3d26962945eda2"}, + {file = "email_validator-1.1.1-py2.py3-none-any.whl", hash = "sha256:5f246ae8d81ce3000eade06595b7bb55a4cf350d559e890182a1466a21f25067"}, + {file = "email_validator-1.1.1.tar.gz", hash = "sha256:63094045c3e802c3d3d575b18b004a531c36243ca8d1cec785ff6bfcb04185bb"}, ] execnet = [ {file = "execnet-1.7.1-py2.py3-none-any.whl", hash = "sha256:d4efd397930c46415f62f8a31388d6be4f27a91d7550eb79bc64a756e0056547"}, @@ -3752,8 +3753,8 @@ ipython-genutils = [ {file = "ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"}, ] isbnlib = [ - {file = "isbnlib-3.10.0-py2.py3-none-any.whl", hash = "sha256:73a409a525d57a2a13977f34222effeb7ae1c0b223edb2eed6c312ecdd2d3d18"}, - {file = "isbnlib-3.10.0.tar.gz", hash = "sha256:c8510e0ecf479d5cac20f7ffb06d91455c0b41d17deb04f6a50aeee98d52f1dc"}, + {file = "isbnlib-3.10.1-py2.py3-none-any.whl", hash = "sha256:8452cafff01e95258df4fb3b0328bb814d1b8919fd1ea1337eb6f6d5656f6936"}, + {file = "isbnlib-3.10.1.tar.gz", hash = "sha256:2a63fdbdfc78447c0bb6ae557c3958f2c9b6b3372bde3dbaf000958b96f5c5cf"}, ] isort = [ {file = "isort-4.3.21-py2.py3-none-any.whl", hash = "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"}, @@ -3900,8 +3901,8 @@ mock = [ {file = "mock-4.0.2.tar.gz", hash = "sha256:dd33eb70232b6118298d516bbcecd26704689c386594f0f3c4f13867b2c56f72"}, ] more-itertools = [ - {file = "more-itertools-8.2.0.tar.gz", hash = "sha256:b1ddb932186d8a6ac451e1d95844b382f55e12686d51ca0c68b6f61f2ab7a507"}, - {file = "more_itertools-8.2.0-py3-none-any.whl", hash = "sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c"}, + {file = "more-itertools-8.3.0.tar.gz", hash = "sha256:558bb897a2232f5e4f8e2399089e35aecb746e1f9191b6584a151647e89267be"}, + {file = "more_itertools-8.3.0-py3-none-any.whl", hash = "sha256:7818f596b1e87be009031c7653d01acc46ed422e6656b394b0f765ce66ed4982"}, ] msgpack = [ {file = "msgpack-1.0.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:cec8bf10981ed70998d98431cd814db0ecf3384e6b113366e7f36af71a0fca08"}, @@ -3931,8 +3932,8 @@ oauthlib = [ {file = "oauthlib-2.1.0.tar.gz", hash = "sha256:ac35665a61c1685c56336bda97d5eefa246f1202618a1d6f34fccb1bdd404162"}, ] packaging = [ - {file = "packaging-20.3-py2.py3-none-any.whl", hash = "sha256:82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752"}, - {file = "packaging-20.3.tar.gz", hash = "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"}, + {file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"}, + {file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"}, ] parso = [ {file = "parso-0.7.0-py2.py3-none-any.whl", hash = "sha256:158c140fc04112dc45bca311633ae5033c2c2a7b732fa33d0955bad8152a8dd0"}, @@ -4124,34 +4125,34 @@ raven = [ {file = "raven-5.33.0.tar.gz", hash = "sha256:85af57123d22e9cbe6d1de671c27d337cec45b22e7d5b907578281f8384a2822"}, ] redis = [ - {file = "redis-3.5.1-py2.py3-none-any.whl", hash = "sha256:a5b0e25890d216d8189636742c50ab992e42eea699bcc1b08cc2d6bf3adff52a"}, - {file = "redis-3.5.1.tar.gz", hash = "sha256:6e9d2722a95d10ddf854596e66516d316d99c6a483e5db3b35c34e1158b2bfa1"}, + {file = "redis-3.5.2-py2.py3-none-any.whl", hash = "sha256:2ef11f489003f151777c064c5dbc6653dfb9f3eade159bcadc524619fddc2242"}, + {file = "redis-3.5.2.tar.gz", hash = "sha256:6d65e84bc58091140081ee9d9c187aab0480097750fac44239307a3bdf0b1251"}, ] redisbeat = [ {file = "redisbeat-1.2.2.tar.gz", hash = "sha256:59b7e9984cb9cde9eaea21093ca2b953f83995a64b6c240e4c36f1b2e9ed1e38"}, ] regex = [ - {file = "regex-2020.5.13-cp27-cp27m-win32.whl", hash = "sha256:d20ba8d3a844d6cd9bbe127a60cc8f61cfe2d2b77da997775639999a48fbbfe3"}, - {file = "regex-2020.5.13-cp27-cp27m-win_amd64.whl", hash = "sha256:2cdf6bb8112a6b49092a9320edc823d41b21a06c8c7ac88a845b73462193f3ac"}, - {file = "regex-2020.5.13-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:9d801d3693c5a6af5a506f9905b0e6d8ae419a00054d8d80ed9d65f81fc37e1f"}, - {file = "regex-2020.5.13-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:705e334ac42cf807f33d4daafe58da33e23a93389233ab2f80f63dee09488d9b"}, - {file = "regex-2020.5.13-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:78014742b047ea2c9849e85db2dc84cad365b7f2dee404f86882d1fb9ff38df2"}, - {file = "regex-2020.5.13-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:078024a52a72c98f157c380bea7beab7e0b907854ca337e3d4eecd44b363d4fb"}, - {file = "regex-2020.5.13-cp36-cp36m-win32.whl", hash = "sha256:4088da3b99f1341c2904679ffbfe6f08f5cc13e5cad1c6b053728da7cf68d28c"}, - {file = "regex-2020.5.13-cp36-cp36m-win_amd64.whl", hash = "sha256:14026bf953137a5cdc6a2a8fda314a0296ce5cd6da6e46fe79d6e03caf3c1bac"}, - {file = "regex-2020.5.13-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:03284826c5f5cd4b252ab7d510cb4d6b7e7f849cdea8e1b384c57e0996a9a3f9"}, - {file = "regex-2020.5.13-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:36e6e7ca33a70f859e532110c2b1af28f98622424681e2e158f0f49735f1a9c8"}, - {file = "regex-2020.5.13-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:707d2fcfdce12ca946830839c4c243c1b258c0d2c61350dc2efe0af00a4d2fdf"}, - {file = "regex-2020.5.13-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:76668d1f91af08275313799bbd6ab04971ab08919defde886f5c94c7fc0f4623"}, - {file = "regex-2020.5.13-cp37-cp37m-win32.whl", hash = "sha256:0be1cb724d43a7fb017e868d809640de03be7db88ab83d212fd802bc3d0277a0"}, - {file = "regex-2020.5.13-cp37-cp37m-win_amd64.whl", hash = "sha256:9d42213927eede46bd4eb0c225600d82cf2b3c8882eb449f00b7cfa9bbf0975e"}, - {file = "regex-2020.5.13-cp38-cp38-manylinux1_i686.whl", hash = "sha256:7163cac9621e9099dc8768ddec32372f50893c934be961f58826d46f0668ea0c"}, - {file = "regex-2020.5.13-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:efae79f5eb3a6e2d9fa246605870887e0187ed66a4c56fc4cf22da00aa2ec220"}, - {file = "regex-2020.5.13-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:89d4a97682170c32a13c4223e72cf75f9d0c6223b40fb4abe717bbb6c271c6ea"}, - {file = "regex-2020.5.13-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:4f144eb977800d7ef593893204c2e7f1f109e8a943f6e822990d22385b12c5d6"}, - {file = "regex-2020.5.13-cp38-cp38-win32.whl", hash = "sha256:3b7f9c0051179325d7efd76271b783de593a50608e48e130c1590a95ea411f59"}, - {file = "regex-2020.5.13-cp38-cp38-win_amd64.whl", hash = "sha256:3cec763e0428beb8668edf004aa9a8a4c1b502d0ecb97dc4d77e5a67a9077186"}, - {file = "regex-2020.5.13.tar.gz", hash = "sha256:cd931f9cca663617ba7a74b6500c6857405271b142edff68b2530e458b80a116"}, + {file = "regex-2020.5.14-cp27-cp27m-win32.whl", hash = "sha256:e565569fc28e3ba3e475ec344d87ed3cd8ba2d575335359749298a0899fe122e"}, + {file = "regex-2020.5.14-cp27-cp27m-win_amd64.whl", hash = "sha256:d466967ac8e45244b9dfe302bbe5e3337f8dc4dec8d7d10f5e950d83b140d33a"}, + {file = "regex-2020.5.14-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:27ff7325b297fb6e5ebb70d10437592433601c423f5acf86e5bc1ee2919b9561"}, + {file = "regex-2020.5.14-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:ea55b80eb0d1c3f1d8d784264a6764f931e172480a2f1868f2536444c5f01e01"}, + {file = "regex-2020.5.14-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:c9bce6e006fbe771a02bda468ec40ffccbf954803b470a0345ad39c603402577"}, + {file = "regex-2020.5.14-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:d881c2e657c51d89f02ae4c21d9adbef76b8325fe4d5cf0e9ad62f850f3a98fd"}, + {file = "regex-2020.5.14-cp36-cp36m-win32.whl", hash = "sha256:99568f00f7bf820c620f01721485cad230f3fb28f57d8fbf4a7967ec2e446994"}, + {file = "regex-2020.5.14-cp36-cp36m-win_amd64.whl", hash = "sha256:70c14743320a68c5dac7fc5a0f685be63bc2024b062fe2aaccc4acc3d01b14a1"}, + {file = "regex-2020.5.14-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:a7c37f048ec3920783abab99f8f4036561a174f1314302ccfa4e9ad31cb00eb4"}, + {file = "regex-2020.5.14-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:89d76ce33d3266173f5be80bd4efcbd5196cafc34100fdab814f9b228dee0fa4"}, + {file = "regex-2020.5.14-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:51f17abbe973c7673a61863516bdc9c0ef467407a940f39501e786a07406699c"}, + {file = "regex-2020.5.14-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:ce5cc53aa9fbbf6712e92c7cf268274eaff30f6bd12a0754e8133d85a8fb0f5f"}, + {file = "regex-2020.5.14-cp37-cp37m-win32.whl", hash = "sha256:8044d1c085d49673aadb3d7dc20ef5cb5b030c7a4fa253a593dda2eab3059929"}, + {file = "regex-2020.5.14-cp37-cp37m-win_amd64.whl", hash = "sha256:c2062c7d470751b648f1cacc3f54460aebfc261285f14bc6da49c6943bd48bdd"}, + {file = "regex-2020.5.14-cp38-cp38-manylinux1_i686.whl", hash = "sha256:329ba35d711e3428db6b45a53b1b13a0a8ba07cbbcf10bbed291a7da45f106c3"}, + {file = "regex-2020.5.14-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:579ea215c81d18da550b62ff97ee187b99f1b135fd894a13451e00986a080cad"}, + {file = "regex-2020.5.14-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:3a9394197664e35566242686d84dfd264c07b20f93514e2e09d3c2b3ffdf78fe"}, + {file = "regex-2020.5.14-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:ce367d21f33e23a84fb83a641b3834dd7dd8e9318ad8ff677fbfae5915a239f7"}, + {file = "regex-2020.5.14-cp38-cp38-win32.whl", hash = "sha256:1386e75c9d1574f6aa2e4eb5355374c8e55f9aac97e224a8a5a6abded0f9c927"}, + {file = "regex-2020.5.14-cp38-cp38-win_amd64.whl", hash = "sha256:7e61be8a2900897803c293247ef87366d5df86bf701083b6c43119c7c6c99108"}, + {file = "regex-2020.5.14.tar.gz", hash = "sha256:ce450ffbfec93821ab1fea94779a8440e10cf63819be6e176eb1973a6017aff5"}, ] requests = [ {file = "requests-2.23.0-py2.py3-none-any.whl", hash = "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee"}, @@ -4175,8 +4176,8 @@ sentry-sdk = [ {file = "sentry_sdk-0.14.4-py2.py3-none-any.whl", hash = "sha256:799a8bf76b012e3030a881be00e97bc0b922ce35dde699c6537122b751d80e2c"}, ] sickle = [ - {file = "Sickle-0.6.5-py3-none-any.whl", hash = "sha256:efdfa46c40cd34b3550f11b59c607ff0bd63adbc074efaa8b4dd662108269a2f"}, - {file = "Sickle-0.6.5.tar.gz", hash = "sha256:c0841b4df5edea33d2da01e893b3feadb1a8eacd2ca4dab9248e6047455ba14a"}, + {file = "Sickle-0.7.0-py3-none-any.whl", hash = "sha256:6ace7b1d1fc76571fe0dbfefc2c49e5e6c026e2d0dcaae521f4da21e98d4bc85"}, + {file = "Sickle-0.7.0.tar.gz", hash = "sha256:8944bcda3db0109a361248ef71fef476dd1f11109cdd1a41135527b7992b958b"}, ] simplejson = [ {file = "simplejson-3.17.0-cp27-cp27m-macosx_10_13_x86_64.whl", hash = "sha256:87d349517b572964350cc1adc5a31b493bbcee284505e81637d0174b2758ba17"}, diff --git a/pyproject.toml b/pyproject.toml index 1d81f9299b..be28d9a80d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ polib = "*" pycountry = ">=19.7.15" xmltodict = "*" redisbeat = "*" +jsonpickle = "*" # TODO: to be removed when the thumbnail will be refactored angular-gettext-babel= ">=0.1" @@ -94,7 +95,6 @@ docutils = "*" autoflake = ">=1.3.1" transifex-client = ">=0.12.5" appnope = { version = "*", optional = true } -jsonpickle = "*" [tool.poetry.scripts] bootstrap = "scripts:run('./scripts/bootstrap')" diff --git a/rero_ils/modules/documents/api.py b/rero_ils/modules/documents/api.py index 402f677cbe..1835e8f9c9 100644 --- a/rero_ils/modules/documents/api.py +++ b/rero_ils/modules/documents/api.py @@ -182,12 +182,17 @@ def dumps(self, **kwargs): def index_persons(self, bulk=False): """Index all attached persons.""" + from ..persons.api import Person persons_ids = [] for author in self.get('authors', []): + person = None ref = author.get('$ref') if ref: - from ..persons.api import Person person = Person.get_record_by_ref(ref) + pid = author.get('pid') + if pid: + person = Person.get_record_by_pid(pid) + if person: if bulk: persons_ids.append(person.id) else: @@ -213,9 +218,9 @@ def replace_refs(self): for idx, author in enumerate(authors): ref = author.get('$ref') if ref: - pers = Person.get_record_by_ref(ref) - if pers: - authors[idx] = pers + person = Person.get_record_by_ref(ref) + if person: + authors[idx] = person return super(Document, self).replace_refs() diff --git a/scripts/__init__.py b/scripts/__init__.py index f7b32740e4..991e317754 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -18,7 +18,7 @@ """Poetry script utils.""" import os -import subprocess +# import subprocess import sys # def __getattr__(name): # python 3.7+, otherwise define each script manually diff --git a/scripts/setup b/scripts/setup index fde95a38e1..3cc66577da 100755 --- a/scripts/setup +++ b/scripts/setup @@ -162,7 +162,7 @@ celery purge -A rero_ils.celery -f # Clean redis info_msg "Clean redis" eval "${PREFIX} invenio shell --no-term-title -c \"import redis; redis.StrictRedis.from_url(app.config['CACHE_REDIS_URL']).flushall(); print('Cache cleared')\"" -eval ${PREFIX} pipenv run invenio scheduler init -r +eval ${PREFIX} invenio scheduler init -r eval ${PREFIX} invenio db destroy --yes-i-know eval ${PREFIX} invenio db init create @@ -370,8 +370,10 @@ then eval ${PREFIX} invenio oaiharvester harvest -n ebooks -q -k else eval ${PREFIX} invenio scheduler enable_tasks -n bulk-indexer -n notification-creation -n accounts -n clear_and_renew_subscriptions -v - info_msg "Start OAI harvesting 100" - eval ${PREFIX} invenio oaiharvester harvest -n ebooks -a max=100 -q + info_msg "For ebooks harvesting run:" + msg "\tinvenio oaiharvester harvest -n ebooks -a max=100 -q" + # info_msg "Start OAI harvesting 100" + # eval ${PREFIX} invenio oaiharvester harvest -n ebooks -a max=100 -q fi if ${ES_MAPPING} diff --git a/tests/ui/documents/test_documents_api.py b/tests/ui/documents/test_documents_api.py index 2b795c992a..b0d463c1b4 100644 --- a/tests/ui/documents/test_documents_api.py +++ b/tests/ui/documents/test_documents_api.py @@ -139,6 +139,10 @@ def test_document_can_delete_with_loans( def test_document_person_resolve_exception(es_clear, db, document_data_ref): """Test document person resolve.""" + document_data_ref['authors'] = [{ + '$ref': 'https://mef.rero.ch/api/rero/XXXXXX', + 'type': 'person' + }], with pytest.raises(Exception): Document.create( data=document_data_ref,