invenio-app-ils 1.0.0a54__py2.py3-none-any.whl → 6.1.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- invenio_app_ils/__init__.py +2 -2
- invenio_app_ils/acquisition/api.py +3 -1
- invenio_app_ils/acquisition/config.py +10 -21
- invenio_app_ils/acquisition/jsonresolvers/order_order_lines.py +1 -0
- invenio_app_ils/acquisition/mappings/os-v1/acq_orders/order-v1.0.0.json +364 -0
- invenio_app_ils/acquisition/mappings/os-v2/__init__.py +0 -0
- invenio_app_ils/acquisition/mappings/os-v2/acq_orders/order-v1.0.0.json +364 -0
- invenio_app_ils/acquisition/mappings/v7/acq_orders/order-v1.0.0.json +14 -0
- invenio_app_ils/acquisition/search.py +5 -15
- invenio_app_ils/assets/semantic-ui/less/theme.config +103 -0
- invenio_app_ils/assets/semantic-ui/templates/.gitkeep +0 -0
- invenio_app_ils/circulation/api.py +153 -67
- invenio_app_ils/circulation/config.py +29 -25
- invenio_app_ils/circulation/indexer.py +14 -19
- invenio_app_ils/circulation/loaders/__init__.py +2 -0
- invenio_app_ils/circulation/loaders/schemas/json/loan_checkout.py +2 -3
- invenio_app_ils/circulation/loaders/schemas/json/loan_request.py +82 -16
- invenio_app_ils/circulation/loaders/schemas/json/loan_self_checkout.py +19 -0
- invenio_app_ils/circulation/notifications/api.py +23 -19
- invenio_app_ils/circulation/notifications/messages.py +6 -6
- invenio_app_ils/circulation/notifications/tasks.py +1 -2
- invenio_app_ils/circulation/receivers.py +2 -5
- invenio_app_ils/circulation/search.py +23 -22
- invenio_app_ils/circulation/serializers/__init__.py +2 -2
- invenio_app_ils/circulation/serializers/csv.py +1 -3
- invenio_app_ils/circulation/serializers/custom_fields.py +5 -9
- invenio_app_ils/circulation/serializers/json.py +2 -6
- invenio_app_ils/circulation/serializers/response.py +12 -12
- invenio_app_ils/circulation/stats/views.py +5 -15
- invenio_app_ils/circulation/tasks.py +2 -6
- invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/self_checkout.html +19 -0
- invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/update_dates.html +19 -0
- invenio_app_ils/circulation/utils.py +23 -17
- invenio_app_ils/circulation/views.py +103 -39
- invenio_app_ils/cli.py +220 -260
- invenio_app_ils/closures/api.py +72 -7
- invenio_app_ils/closures/serializers/__init__.py +16 -0
- invenio_app_ils/closures/serializers/response.py +35 -0
- invenio_app_ils/closures/serializers/schema.py +28 -0
- invenio_app_ils/closures/tasks.py +4 -11
- invenio_app_ils/closures/views.py +66 -0
- invenio_app_ils/config.py +207 -150
- invenio_app_ils/document_requests/api.py +6 -21
- invenio_app_ils/document_requests/loaders/__init__.py +4 -12
- invenio_app_ils/document_requests/mappings/{v6 → os-v1}/__init__.py +2 -2
- invenio_app_ils/document_requests/mappings/os-v1/document_requests/document_request-v1.0.0.json +196 -0
- invenio_app_ils/document_requests/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/document_requests/mappings/os-v2/document_requests/document_request-v1.0.0.json +196 -0
- invenio_app_ils/document_requests/notifications/api.py +2 -7
- invenio_app_ils/document_requests/notifications/messages.py +3 -7
- invenio_app_ils/document_requests/search.py +2 -6
- invenio_app_ils/document_requests/views.py +4 -10
- invenio_app_ils/documents/api.py +19 -25
- invenio_app_ils/documents/indexer.py +13 -20
- invenio_app_ils/documents/jsonresolvers/document_circulation.py +11 -33
- invenio_app_ils/documents/jsonresolvers/document_eitem.py +1 -0
- invenio_app_ils/documents/jsonresolvers/document_item.py +8 -9
- invenio_app_ils/documents/jsonresolvers/document_stock.py +7 -7
- invenio_app_ils/documents/loaders/jsonschemas/document.py +3 -14
- invenio_app_ils/documents/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/documents/mappings/os-v1/documents/document-v1.0.0.json +932 -0
- invenio_app_ils/documents/mappings/os-v1/documents/document-v2.0.0.json +1066 -0
- invenio_app_ils/documents/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/documents/mappings/os-v2/documents/document-v1.0.0.json +932 -0
- invenio_app_ils/documents/mappings/os-v2/documents/document-v2.0.0.json +1066 -0
- invenio_app_ils/documents/mappings/v7/documents/document-v1.0.0.json +102 -11
- invenio_app_ils/documents/mappings/v7/documents/document-v2.0.0.json +1066 -0
- invenio_app_ils/documents/schemas/documents/document-v2.0.0.json +732 -0
- invenio_app_ils/eitems/api.py +41 -7
- invenio_app_ils/eitems/loaders/jsonschemas/eitems.py +6 -6
- invenio_app_ils/eitems/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v1.0.0.json +139 -0
- invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v2.0.0.json +142 -0
- invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v3.0.0.json +179 -0
- invenio_app_ils/{series/mappings/v6 → eitems/mappings/os-v2}/__init__.py +1 -1
- invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v1.0.0.json +139 -0
- invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v2.0.0.json +142 -0
- invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v3.0.0.json +179 -0
- invenio_app_ils/eitems/mappings/v7/eitems/eitem-v1.0.0.json +12 -2
- invenio_app_ils/eitems/mappings/v7/eitems/eitem-v2.0.0.json +142 -0
- invenio_app_ils/eitems/mappings/v7/eitems/eitem-v3.0.0.json +179 -0
- invenio_app_ils/eitems/schemas/eitems/eitem-v2.0.0.json +120 -0
- invenio_app_ils/eitems/schemas/eitems/eitem-v3.0.0.json +120 -0
- invenio_app_ils/eitems/search.py +3 -9
- invenio_app_ils/errors.py +119 -6
- invenio_app_ils/ext.py +15 -18
- invenio_app_ils/facets.py +13 -15
- invenio_app_ils/files/receivers.py +1 -1
- invenio_app_ils/files/views.py +1 -2
- invenio_app_ils/ill/api.py +1 -2
- invenio_app_ils/ill/config.py +10 -16
- invenio_app_ils/ill/jsonresolvers/borrowing_request_document.py +2 -3
- invenio_app_ils/ill/jsonresolvers/borrowing_request_patron.py +1 -3
- invenio_app_ils/ill/jsonresolvers/borrowing_request_provider.py +1 -3
- invenio_app_ils/ill/loaders/__init__.py +3 -9
- invenio_app_ils/ill/loaders/jsonschemas/patron_loan_actions.py +1 -8
- invenio_app_ils/ill/loaders/jsonschemas/patron_loan_extension_actions.py +3 -8
- invenio_app_ils/ill/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/ill/mappings/os-v1/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
- invenio_app_ils/{acquisition/mappings/v6 → ill/mappings/os-v2}/__init__.py +1 -1
- invenio_app_ils/ill/mappings/os-v2/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
- invenio_app_ils/ill/mappings/v7/ill_borrowing_requests/borrowing_request-v1.0.0.json +14 -0
- invenio_app_ils/ill/notifications/api.py +1 -4
- invenio_app_ils/ill/search.py +3 -9
- invenio_app_ils/ill/serializers/__init__.py +1 -3
- invenio_app_ils/ill/views.py +2 -4
- invenio_app_ils/internal_locations/api.py +1 -4
- invenio_app_ils/internal_locations/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/internal_locations/mappings/os-v1/internal_locations/internal_location-v1.0.0.json +108 -0
- invenio_app_ils/internal_locations/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/internal_locations/mappings/os-v2/internal_locations/internal_location-v1.0.0.json +108 -0
- invenio_app_ils/internal_locations/search.py +1 -3
- invenio_app_ils/items/api.py +18 -15
- invenio_app_ils/items/indexer.py +1 -3
- invenio_app_ils/items/jsonresolvers/item_document.py +1 -1
- invenio_app_ils/items/jsonresolvers/item_internal_location.py +2 -6
- invenio_app_ils/items/loaders/jsonschemas/items.py +2 -0
- {tests/api/circulation → invenio_app_ils/items/mappings/os-v1}/__init__.py +1 -1
- invenio_app_ils/items/mappings/os-v1/items/item-v1.0.0.json +285 -0
- invenio_app_ils/items/mappings/os-v1/items/item-v2.0.0.json +326 -0
- {tests/api/ill → invenio_app_ils/items/mappings/os-v2}/__init__.py +1 -1
- invenio_app_ils/items/mappings/os-v2/items/item-v1.0.0.json +285 -0
- invenio_app_ils/items/mappings/os-v2/items/item-v2.0.0.json +326 -0
- invenio_app_ils/items/mappings/v7/items/item-v1.0.0.json +11 -0
- invenio_app_ils/items/mappings/v7/items/item-v2.0.0.json +326 -0
- invenio_app_ils/items/schemas/items/item-v1.0.0.json +22 -0
- invenio_app_ils/items/schemas/items/item-v2.0.0.json +172 -0
- invenio_app_ils/items/search.py +18 -11
- invenio_app_ils/items/serializers/item.py +7 -6
- invenio_app_ils/literature/api.py +1 -3
- invenio_app_ils/literature/search.py +3 -5
- invenio_app_ils/literature/serializers/csv.py +1 -3
- invenio_app_ils/literature/serializers/json.py +1 -3
- invenio_app_ils/locations/api.py +2 -4
- invenio_app_ils/locations/indexer.py +3 -9
- invenio_app_ils/locations/loaders/__init__.py +1 -3
- invenio_app_ils/locations/loaders/jsonschemas/location.py +4 -11
- invenio_app_ils/locations/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/locations/mappings/os-v1/locations/location-v1.0.0.json +90 -0
- invenio_app_ils/locations/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/locations/mappings/os-v2/locations/location-v1.0.0.json +90 -0
- invenio_app_ils/notifications/messages.py +4 -3
- invenio_app_ils/notifications/tasks.py +1 -3
- invenio_app_ils/notifications/views.py +2 -2
- invenio_app_ils/patrons/anonymization.py +53 -32
- invenio_app_ils/patrons/api.py +3 -5
- invenio_app_ils/patrons/cli.py +1 -2
- invenio_app_ils/patrons/indexer.py +4 -13
- invenio_app_ils/patrons/mappings/os-v1/__init__.py +8 -0
- invenio_app_ils/patrons/mappings/os-v1/patrons/patron-v1.0.0.json +42 -0
- invenio_app_ils/patrons/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/patrons/mappings/os-v2/patrons/patron-v1.0.0.json +42 -0
- invenio_app_ils/patrons/views.py +4 -14
- invenio_app_ils/permissions.py +93 -35
- invenio_app_ils/providers/api.py +2 -6
- invenio_app_ils/providers/config.py +11 -19
- invenio_app_ils/providers/indexer.py +2 -6
- invenio_app_ils/providers/mappings/{v6 → os-v1}/__init__.py +1 -1
- invenio_app_ils/providers/mappings/os-v1/providers/provider-v1.0.0.json +57 -0
- invenio_app_ils/providers/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/providers/mappings/os-v2/providers/provider-v1.0.0.json +57 -0
- invenio_app_ils/providers/mappings/v7/__init__.py +1 -1
- invenio_app_ils/providers/proxies.py +1 -3
- invenio_app_ils/records/api.py +3 -9
- invenio_app_ils/records/loaders/schemas/changed_by.py +1 -3
- invenio_app_ils/records/loaders/schemas/identifiers.py +23 -0
- invenio_app_ils/records/metadata_extensions.py +1 -4
- invenio_app_ils/records/permissions.py +8 -2
- invenio_app_ils/records/serializers/__init__.py +1 -4
- invenio_app_ils/records/views.py +4 -7
- invenio_app_ils/records_relations/api.py +11 -34
- invenio_app_ils/records_relations/indexer.py +1 -3
- invenio_app_ils/records_relations/retriever.py +14 -9
- invenio_app_ils/records_relations/views.py +16 -50
- invenio_app_ils/relations/api.py +17 -16
- invenio_app_ils/search_permissions.py +24 -24
- invenio_app_ils/series/api.py +10 -12
- invenio_app_ils/series/loaders/jsonschemas/series.py +3 -2
- invenio_app_ils/{items/mappings/v6 → series/mappings/os-v1}/__init__.py +1 -1
- invenio_app_ils/series/mappings/os-v1/series/series-v1.0.0.json +324 -0
- invenio_app_ils/series/mappings/os-v1/series/series-v2.0.0.json +396 -0
- {tests/api/acquisition → invenio_app_ils/series/mappings/os-v2}/__init__.py +1 -1
- invenio_app_ils/series/mappings/os-v2/series/series-v1.0.0.json +324 -0
- invenio_app_ils/series/mappings/os-v2/series/series-v2.0.0.json +396 -0
- invenio_app_ils/series/mappings/v7/series/series-v1.0.0.json +35 -3
- invenio_app_ils/series/mappings/v7/series/series-v2.0.0.json +396 -0
- invenio_app_ils/series/schemas/series/series-v2.0.0.json +354 -0
- invenio_app_ils/stats/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.json +60 -0
- invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/__init__.py +9 -0
- invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.json +60 -0
- invenio_app_ils/stats/event_builders.py +73 -0
- invenio_app_ils/stats/file_download/os-v1/file-download-v1.json +72 -0
- invenio_app_ils/stats/file_download/os-v2/__init__.py +9 -0
- invenio_app_ils/stats/file_download/os-v2/file-download-v1.json +72 -0
- invenio_app_ils/stats/processors.py +30 -0
- invenio_app_ils/stats/templates/aggregations/__init__.py +8 -0
- invenio_app_ils/stats/templates/aggregations/ils_record_changes/__init__.py +8 -0
- invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/__init__.py +8 -0
- invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/aggr-ils-record-changes-v1.json +41 -0
- {tests → invenio_app_ils/stats/templates/events}/__init__.py +2 -2
- invenio_app_ils/stats/templates/events/ils_record_changes/__init__.py +8 -0
- invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/__init__.py +8 -0
- invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/ils-record-changes-v1.json +41 -0
- invenio_app_ils/templates/logged_out.html +12 -0
- invenio_app_ils/views.py +18 -4
- invenio_app_ils/vocabularies/api.py +1 -1
- invenio_app_ils/vocabularies/cli.py +6 -18
- invenio_app_ils/vocabularies/data/acq_order_line_payment_modes.json +5 -0
- invenio_app_ils/vocabularies/data/identifier_schemes.json +5 -0
- invenio_app_ils/vocabularies/indexer.py +1 -4
- invenio_app_ils/vocabularies/jsonresolvers/licenses.py +2 -11
- invenio_app_ils/vocabularies/mappings/os-v1/__init__.py +8 -0
- invenio_app_ils/vocabularies/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +23 -0
- invenio_app_ils/vocabularies/mappings/os-v2/__init__.py +8 -0
- invenio_app_ils/vocabularies/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +23 -0
- invenio_app_ils/vocabularies/sources/base.py +1 -3
- invenio_app_ils/webpack.py +27 -0
- invenio_app_ils-6.1.0.dist-info/METADATA +627 -0
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/RECORD +227 -249
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/WHEEL +1 -1
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/entry_points.txt +9 -5
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/top_level.txt +0 -1
- invenio_app_ils/acquisition/mappings/v6/acq_orders/order-v1.0.0.json +0 -352
- invenio_app_ils/document_requests/mappings/v6/document_requests/document_request-v1.0.0.json +0 -199
- invenio_app_ils/documents/mappings/v6/documents/document-v1.0.0.json +0 -843
- invenio_app_ils/eitems/mappings/v6/eitems/eitem-v1.0.0.json +0 -131
- invenio_app_ils/ill/mappings/v6/ill_borrowing_requests/borrowing_request-v1.0.0.json +0 -242
- invenio_app_ils/internal_locations/mappings/v6/internal_locations/internal_location-v1.0.0.json +0 -110
- invenio_app_ils/items/mappings/v6/items/item-v1.0.0.json +0 -276
- invenio_app_ils/locations/mappings/v6/locations/location-v1.0.0.json +0 -92
- invenio_app_ils/notifications/admin.py +0 -57
- invenio_app_ils/patrons/mappings/v6/__init__.py +0 -8
- invenio_app_ils/patrons/mappings/v6/patrons/patron-v1.0.0.json +0 -44
- invenio_app_ils/providers/mappings/v6/providers/provider-v1.0.0.json +0 -59
- invenio_app_ils/series/mappings/v6/series/series-v1.0.0.json +0 -298
- invenio_app_ils/stats/aggregations/aggr_file_download/v6/aggr-file-download-v1.json +0 -59
- invenio_app_ils/stats/file_download/v6/file-download-v1.json +0 -74
- invenio_app_ils/version.py +0 -14
- invenio_app_ils/vocabularies/mappings/v6/__init__.py +0 -8
- invenio_app_ils/vocabularies/mappings/v6/vocabularies/vocabulary-v1.0.0.json +0 -25
- invenio_app_ils-1.0.0a54.dist-info/METADATA +0 -95
- tests/api/__init__.py +0 -8
- tests/api/acquisition/test_acq_orders_crud.py +0 -102
- tests/api/acquisition/test_acq_orders_permissions.py +0 -104
- tests/api/acquisition/test_acq_providers_permissions.py +0 -83
- tests/api/circulation/test_expired_loans.py +0 -88
- tests/api/circulation/test_loan_checkout.py +0 -216
- tests/api/circulation/test_loan_default_durations.py +0 -57
- tests/api/circulation/test_loan_document_resolver.py +0 -18
- tests/api/circulation/test_loan_extend.py +0 -132
- tests/api/circulation/test_loan_item_permissions.py +0 -139
- tests/api/circulation/test_loan_item_resolver.py +0 -26
- tests/api/circulation/test_loan_list_permissions.py +0 -104
- tests/api/circulation/test_loan_patron_resolver.py +0 -38
- tests/api/circulation/test_loan_request.py +0 -234
- tests/api/circulation/test_loan_update.py +0 -150
- tests/api/circulation/test_notifications.py +0 -229
- tests/api/conftest.py +0 -236
- tests/api/document_requests/__init__.py +0 -8
- tests/api/document_requests/test_document_requests.py +0 -131
- tests/api/document_requests/test_document_requests_permissions.py +0 -177
- tests/api/document_requests/test_notifications_filter.py +0 -36
- tests/api/ill/test_ill_brw_crud.py +0 -84
- tests/api/ill/test_ill_brw_reqs_patron_loan_create_action.py +0 -207
- tests/api/ill/test_ill_brw_reqs_patron_loan_extension_actions.py +0 -298
- tests/api/ill/test_ill_brw_reqs_permissions.py +0 -169
- tests/api/ill/test_ill_providers_permissions.py +0 -82
- tests/api/ils/__init__.py +0 -8
- tests/api/ils/documents/__init__.py +0 -8
- tests/api/ils/documents/test_document_crud.py +0 -57
- tests/api/ils/documents/test_document_permissions.py +0 -106
- tests/api/ils/documents/test_document_resolvers.py +0 -35
- tests/api/ils/eitems/__init__.py +0 -8
- tests/api/ils/eitems/test_eitems_crud.py +0 -41
- tests/api/ils/eitems/test_eitems_permissions.py +0 -84
- tests/api/ils/eitems/test_files.py +0 -172
- tests/api/ils/items/__init__.py +0 -8
- tests/api/ils/items/test_apis.py +0 -43
- tests/api/ils/items/test_items_crud.py +0 -60
- tests/api/ils/items/test_items_permissions.py +0 -107
- tests/api/ils/items/test_items_update.py +0 -47
- tests/api/ils/records_relations/__init__.py +0 -8
- tests/api/ils/records_relations/helpers.py +0 -115
- tests/api/ils/records_relations/test_records_relations_parentchild.py +0 -560
- tests/api/ils/records_relations/test_records_relations_sequence.py +0 -302
- tests/api/ils/records_relations/test_records_relations_siblings.py +0 -678
- tests/api/ils/series/__init__.py +0 -8
- tests/api/ils/series/test_series_permissions.py +0 -95
- tests/api/ils/test_anonymization.py +0 -189
- tests/api/ils/test_apis.py +0 -76
- tests/api/ils/test_closures.py +0 -324
- tests/api/ils/test_errors.py +0 -126
- tests/api/ils/test_facets.py +0 -84
- tests/api/ils/test_internal_locations.py +0 -96
- tests/api/ils/test_loaders.py +0 -55
- tests/api/ils/test_metadata_extensions.py +0 -205
- tests/api/ils/test_notifications.py +0 -183
- tests/api/ils/test_notifications_mails.py +0 -39
- tests/api/ils/test_notifications_permissions.py +0 -55
- tests/api/ils/test_patrons.py +0 -106
- tests/api/ils/test_record_delete.py +0 -46
- tests/api/ils/test_record_permissions.py +0 -135
- tests/api/ils/test_resolvers.py +0 -207
- tests/api/ils/test_stats.py +0 -160
- tests/api/ils/test_tasks.py +0 -211
- tests/api/ils/test_vocabularies.py +0 -35
- tests/conftest.py +0 -123
- tests/data/acq_orders.json +0 -89
- tests/data/acq_providers.json +0 -12
- tests/data/document_requests.json +0 -77
- tests/data/documents.json +0 -237
- tests/data/eitems.json +0 -66
- tests/data/ill_borrowing_requests.json +0 -77
- tests/data/ill_providers.json +0 -12
- tests/data/internal_locations.json +0 -22
- tests/data/items.json +0 -271
- tests/data/loans.json +0 -133
- tests/data/loans_most_loaned.json +0 -128
- tests/data/locations.json +0 -20
- tests/data/series.json +0 -33
- tests/helpers.py +0 -104
- tests/templates/notifications/title_body.html +0 -8
- tests/templates/notifications/title_body_html.html +0 -13
- tests/templates/notifications/title_body_html_ctx.html +0 -13
- tests/templates/notifications/title_only.html +0 -3
- tests/test_version.py +0 -17
- /tests/templates/notifications/blank.html → /invenio_app_ils/acquisition/mappings/os-v1/__init__.py +0 -0
- /invenio_app_ils/stats/aggregations/aggr_file_download/{v6 → os-v1}/__init__.py +0 -0
- /invenio_app_ils/stats/file_download/{v6 → os-v1}/__init__.py +0 -0
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/AUTHORS.rst +0 -0
- {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/LICENSE +0 -0
invenio_app_ils/locations/api.py
CHANGED
|
@@ -45,9 +45,7 @@ class Location(IlsRecord):
|
|
|
45
45
|
def delete(self, **kwargs):
|
|
46
46
|
"""Delete Location record."""
|
|
47
47
|
iloc_search = current_app_ils.internal_location_search_cls()
|
|
48
|
-
iloc_search_res = iloc_search.search_by_location_pid(
|
|
49
|
-
location_pid=self["pid"]
|
|
50
|
-
)
|
|
48
|
+
iloc_search_res = iloc_search.search_by_location_pid(location_pid=self["pid"])
|
|
51
49
|
if iloc_search_res.count():
|
|
52
50
|
raise RecordHasReferencesError(
|
|
53
51
|
record_type="Location",
|
|
@@ -60,7 +58,7 @@ class Location(IlsRecord):
|
|
|
60
58
|
try:
|
|
61
59
|
# invalidate cached property
|
|
62
60
|
del current_app_ils.get_default_location_pid
|
|
63
|
-
except AttributeError:
|
|
61
|
+
except (AttributeError, KeyError):
|
|
64
62
|
pass
|
|
65
63
|
|
|
66
64
|
return rec
|
|
@@ -26,14 +26,10 @@ def get_internal_locations(location_pid):
|
|
|
26
26
|
intloc_search_cls = current_app_ils.internal_location_search_cls
|
|
27
27
|
intloc_record_cls = current_app_ils.internal_location_record_cls
|
|
28
28
|
for iloc in (
|
|
29
|
-
intloc_search_cls()
|
|
30
|
-
.search_by_location_pid(location_pid=location_pid)
|
|
31
|
-
.scan()
|
|
29
|
+
intloc_search_cls().search_by_location_pid(location_pid=location_pid).scan()
|
|
32
30
|
):
|
|
33
31
|
intloc = intloc_record_cls.get_record_by_pid(iloc["pid"])
|
|
34
|
-
referenced.append(
|
|
35
|
-
dict(pid_type=INTERNAL_LOCATION_PID_TYPE, record=intloc)
|
|
36
|
-
)
|
|
32
|
+
referenced.append(dict(pid_type=INTERNAL_LOCATION_PID_TYPE, record=intloc))
|
|
37
33
|
return referenced
|
|
38
34
|
|
|
39
35
|
|
|
@@ -43,9 +39,7 @@ def get_items(location_pid):
|
|
|
43
39
|
item_search_cls = current_app_ils.item_search_cls
|
|
44
40
|
item_record_cls = current_app_ils.item_record_cls
|
|
45
41
|
for item in (
|
|
46
|
-
item_search_cls()
|
|
47
|
-
.search_by_location_pid(location_pid=location_pid)
|
|
48
|
-
.scan()
|
|
42
|
+
item_search_cls().search_by_location_pid(location_pid=location_pid).scan()
|
|
49
43
|
):
|
|
50
44
|
item = item_record_cls.get_record_by_pid(item["pid"])
|
|
51
45
|
referenced.append(dict(pid_type=ITEM_PID_TYPE, record=item))
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
"""ILS Locations loaders."""
|
|
9
9
|
|
|
10
|
-
from invenio_app_ils.locations.loaders.jsonschemas.location import
|
|
11
|
-
LocationSchemaV1,
|
|
12
|
-
)
|
|
10
|
+
from invenio_app_ils.locations.loaders.jsonschemas.location import LocationSchemaV1
|
|
13
11
|
from invenio_app_ils.records.loaders import ils_marshmallow_loader
|
|
14
12
|
|
|
15
13
|
location_loader = ils_marshmallow_loader(LocationSchemaV1)
|
|
@@ -30,9 +30,7 @@ _WEEKDAY_NAMES = [
|
|
|
30
30
|
"saturday",
|
|
31
31
|
"sunday",
|
|
32
32
|
]
|
|
33
|
-
_WEEKDAY_INDICES = {
|
|
34
|
-
weekday_name: i for i, weekday_name in enumerate(_WEEKDAY_NAMES)
|
|
35
|
-
}
|
|
33
|
+
_WEEKDAY_INDICES = {weekday_name: i for i, weekday_name in enumerate(_WEEKDAY_NAMES)}
|
|
36
34
|
|
|
37
35
|
|
|
38
36
|
def validate_time(value):
|
|
@@ -109,9 +107,7 @@ class OpeningWeekdaySchema(Schema):
|
|
|
109
107
|
previous = None
|
|
110
108
|
for current in times:
|
|
111
109
|
if previous and previous["end_time"] >= current["start_time"]:
|
|
112
|
-
raise ValidationError(
|
|
113
|
-
"Time periods must not overlap.", "times"
|
|
114
|
-
)
|
|
110
|
+
raise ValidationError("Time periods must not overlap.", "times")
|
|
115
111
|
previous = current
|
|
116
112
|
else:
|
|
117
113
|
if "times" in data:
|
|
@@ -156,9 +152,7 @@ class LocationSchemaV1(RecordMetadataSchemaJSONV1):
|
|
|
156
152
|
name = fields.Str(required=True)
|
|
157
153
|
notes = fields.Str()
|
|
158
154
|
opening_exceptions = fields.List(fields.Nested(OpeningExceptionSchema))
|
|
159
|
-
opening_weekdays = fields.List(
|
|
160
|
-
fields.Nested(OpeningWeekdaySchema), required=True
|
|
161
|
-
)
|
|
155
|
+
opening_weekdays = fields.List(fields.Nested(OpeningWeekdaySchema), required=True)
|
|
162
156
|
phone = fields.Str()
|
|
163
157
|
|
|
164
158
|
@post_load
|
|
@@ -174,8 +168,7 @@ class LocationSchemaV1(RecordMetadataSchemaJSONV1):
|
|
|
174
168
|
index = _WEEKDAY_INDICES[name]
|
|
175
169
|
if new_weekdays[index]:
|
|
176
170
|
raise ValidationError(
|
|
177
|
-
"There are two distinct configurations for the "
|
|
178
|
-
"same weekday.",
|
|
171
|
+
"There are two distinct configurations for the " "same weekday.",
|
|
179
172
|
"opening_weekdays",
|
|
180
173
|
)
|
|
181
174
|
new_weekdays[index] = weekday
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"settings": {
|
|
3
|
+
"analysis": {
|
|
4
|
+
"analyzer": {
|
|
5
|
+
"email": {
|
|
6
|
+
"type": "custom",
|
|
7
|
+
"tokenizer": "uax_url_email"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"mappings": {
|
|
13
|
+
"date_detection": false,
|
|
14
|
+
"numeric_detection": false,
|
|
15
|
+
"properties": {
|
|
16
|
+
"$schema": {
|
|
17
|
+
"type": "keyword"
|
|
18
|
+
},
|
|
19
|
+
"_created": {
|
|
20
|
+
"type": "date"
|
|
21
|
+
},
|
|
22
|
+
"_updated": {
|
|
23
|
+
"type": "date"
|
|
24
|
+
},
|
|
25
|
+
"address": {
|
|
26
|
+
"type": "text"
|
|
27
|
+
},
|
|
28
|
+
"email": {
|
|
29
|
+
"type": "text",
|
|
30
|
+
"analyzer": "email"
|
|
31
|
+
},
|
|
32
|
+
"name": {
|
|
33
|
+
"type": "text",
|
|
34
|
+
"fields": {
|
|
35
|
+
"keyword": {
|
|
36
|
+
"type": "keyword"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"notes": {
|
|
41
|
+
"type": "text"
|
|
42
|
+
},
|
|
43
|
+
"opening_exceptions": {
|
|
44
|
+
"properties": {
|
|
45
|
+
"title": {
|
|
46
|
+
"type": "keyword"
|
|
47
|
+
},
|
|
48
|
+
"is_open": {
|
|
49
|
+
"type": "boolean"
|
|
50
|
+
},
|
|
51
|
+
"start_date": {
|
|
52
|
+
"type": "date"
|
|
53
|
+
},
|
|
54
|
+
"end_date": {
|
|
55
|
+
"type": "date"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"type": "object"
|
|
59
|
+
},
|
|
60
|
+
"opening_weekdays": {
|
|
61
|
+
"properties": {
|
|
62
|
+
"weekday": {
|
|
63
|
+
"type": "keyword"
|
|
64
|
+
},
|
|
65
|
+
"is_open": {
|
|
66
|
+
"type": "boolean"
|
|
67
|
+
},
|
|
68
|
+
"times": {
|
|
69
|
+
"properties": {
|
|
70
|
+
"start_time": {
|
|
71
|
+
"type": "text"
|
|
72
|
+
},
|
|
73
|
+
"end_time": {
|
|
74
|
+
"type": "text"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"type": "object"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"type": "object"
|
|
81
|
+
},
|
|
82
|
+
"phone": {
|
|
83
|
+
"type": "keyword"
|
|
84
|
+
},
|
|
85
|
+
"pid": {
|
|
86
|
+
"type": "keyword"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"settings": {
|
|
3
|
+
"analysis": {
|
|
4
|
+
"analyzer": {
|
|
5
|
+
"email": {
|
|
6
|
+
"type": "custom",
|
|
7
|
+
"tokenizer": "uax_url_email"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"mappings": {
|
|
13
|
+
"date_detection": false,
|
|
14
|
+
"numeric_detection": false,
|
|
15
|
+
"properties": {
|
|
16
|
+
"$schema": {
|
|
17
|
+
"type": "keyword"
|
|
18
|
+
},
|
|
19
|
+
"_created": {
|
|
20
|
+
"type": "date"
|
|
21
|
+
},
|
|
22
|
+
"_updated": {
|
|
23
|
+
"type": "date"
|
|
24
|
+
},
|
|
25
|
+
"address": {
|
|
26
|
+
"type": "text"
|
|
27
|
+
},
|
|
28
|
+
"email": {
|
|
29
|
+
"type": "text",
|
|
30
|
+
"analyzer": "email"
|
|
31
|
+
},
|
|
32
|
+
"name": {
|
|
33
|
+
"type": "text",
|
|
34
|
+
"fields": {
|
|
35
|
+
"keyword": {
|
|
36
|
+
"type": "keyword"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"notes": {
|
|
41
|
+
"type": "text"
|
|
42
|
+
},
|
|
43
|
+
"opening_exceptions": {
|
|
44
|
+
"properties": {
|
|
45
|
+
"title": {
|
|
46
|
+
"type": "keyword"
|
|
47
|
+
},
|
|
48
|
+
"is_open": {
|
|
49
|
+
"type": "boolean"
|
|
50
|
+
},
|
|
51
|
+
"start_date": {
|
|
52
|
+
"type": "date"
|
|
53
|
+
},
|
|
54
|
+
"end_date": {
|
|
55
|
+
"type": "date"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"type": "object"
|
|
59
|
+
},
|
|
60
|
+
"opening_weekdays": {
|
|
61
|
+
"properties": {
|
|
62
|
+
"weekday": {
|
|
63
|
+
"type": "keyword"
|
|
64
|
+
},
|
|
65
|
+
"is_open": {
|
|
66
|
+
"type": "boolean"
|
|
67
|
+
},
|
|
68
|
+
"times": {
|
|
69
|
+
"properties": {
|
|
70
|
+
"start_time": {
|
|
71
|
+
"type": "text"
|
|
72
|
+
},
|
|
73
|
+
"end_time": {
|
|
74
|
+
"type": "text"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"type": "object"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"type": "object"
|
|
81
|
+
},
|
|
82
|
+
"phone": {
|
|
83
|
+
"type": "keyword"
|
|
84
|
+
},
|
|
85
|
+
"pid": {
|
|
86
|
+
"type": "keyword"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -50,8 +50,9 @@ class NotificationMsg:
|
|
|
50
50
|
except TemplateError:
|
|
51
51
|
self.body_html = self.body_plain
|
|
52
52
|
|
|
53
|
-
footer_template = current_app.config.get("ILS_NOTIFICATIONS_TEMPLATES",
|
|
54
|
-
|
|
53
|
+
footer_template = current_app.config.get("ILS_NOTIFICATIONS_TEMPLATES", {}).get(
|
|
54
|
+
"footer"
|
|
55
|
+
)
|
|
55
56
|
if footer_template:
|
|
56
57
|
path = os.path.join(self.TEMPLATES_BASE_DIR, footer_template)
|
|
57
58
|
footer_tmpl = current_app.jinja_env.get_template(path)
|
|
@@ -81,7 +82,7 @@ class NotificationMsg:
|
|
|
81
82
|
title=self.title,
|
|
82
83
|
body_plain=self.body_plain,
|
|
83
84
|
body_html=self.body_html,
|
|
84
|
-
msg_cls=self.__class__.__name__
|
|
85
|
+
msg_cls=self.__class__.__name__,
|
|
85
86
|
)
|
|
86
87
|
|
|
87
88
|
|
|
@@ -54,7 +54,5 @@ def log_error_notification(request, exc, traceback, data, **kwargs):
|
|
|
54
54
|
exception=repr(exc),
|
|
55
55
|
data=data,
|
|
56
56
|
)
|
|
57
|
-
current_app.logger.exception(
|
|
58
|
-
json.dumps(error, sort_keys=True), exc_info=exc
|
|
59
|
-
)
|
|
57
|
+
current_app.logger.exception(json.dumps(error, sort_keys=True), exc_info=exc)
|
|
60
58
|
_log_notification_to_db(data, "Error: " + repr(exc))
|
|
@@ -38,7 +38,7 @@ def get_notifications_blueprint(_):
|
|
|
38
38
|
"size": fields.Int(validate=[validate.Range(min=1, max=100)]),
|
|
39
39
|
}
|
|
40
40
|
)
|
|
41
|
-
@need_permissions("
|
|
41
|
+
@need_permissions("get-notifications-sent-to-patron")
|
|
42
42
|
def get_notifications(
|
|
43
43
|
recipient_user_id=None,
|
|
44
44
|
pid_type=None,
|
|
@@ -69,7 +69,7 @@ def get_notifications_blueprint(_):
|
|
|
69
69
|
return {"hits": notifications, "total": len(notifications)}
|
|
70
70
|
|
|
71
71
|
@blueprint.route("/notifications/<int:id>")
|
|
72
|
-
@need_permissions("
|
|
72
|
+
@need_permissions("get-notifications-sent-to-patron")
|
|
73
73
|
def get_notification(id):
|
|
74
74
|
try:
|
|
75
75
|
notification = NotificationsLogs.query.filter_by(id=id).one()
|
|
@@ -10,23 +10,24 @@
|
|
|
10
10
|
|
|
11
11
|
from copy import deepcopy
|
|
12
12
|
|
|
13
|
-
from elasticsearch.exceptions import NotFoundError
|
|
14
13
|
from flask import current_app
|
|
15
|
-
from invenio_accounts.models import SessionActivity, User, userrole
|
|
14
|
+
from invenio_accounts.models import LoginInformation, SessionActivity, User, userrole
|
|
15
|
+
from invenio_circulation.pidstore.pids import CIRCULATION_LOAN_PID_TYPE
|
|
16
16
|
from invenio_circulation.proxies import current_circulation
|
|
17
17
|
from invenio_db import db
|
|
18
18
|
from invenio_oauthclient.models import RemoteAccount, RemoteToken, UserIdentity
|
|
19
|
+
from invenio_search.engine import search as inv_search
|
|
19
20
|
from invenio_userprofiles.models import UserProfile
|
|
20
21
|
|
|
22
|
+
from invenio_app_ils.acquisition.api import ORDER_PID_TYPE
|
|
21
23
|
from invenio_app_ils.acquisition.proxies import current_ils_acq
|
|
22
24
|
from invenio_app_ils.circulation.search import (
|
|
23
25
|
get_active_loans_by_patron_pid,
|
|
24
26
|
get_loans_by_patron_pid,
|
|
25
27
|
)
|
|
26
|
-
from invenio_app_ils.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
28
|
+
from invenio_app_ils.document_requests.api import DOCUMENT_REQUEST_PID_TYPE
|
|
29
|
+
from invenio_app_ils.errors import AnonymizationActiveLoansError, PatronNotFoundError
|
|
30
|
+
from invenio_app_ils.ill.api import BORROWING_REQUEST_PID_TYPE
|
|
30
31
|
from invenio_app_ils.ill.proxies import current_ils_ill
|
|
31
32
|
from invenio_app_ils.notifications.models import NotificationsLogs
|
|
32
33
|
from invenio_app_ils.patrons.api import get_patron_or_unknown_dump
|
|
@@ -59,7 +60,6 @@ def get_patron_activity(patron_pid):
|
|
|
59
60
|
patron_loans = dump(get_loans_by_patron_pid(patron_pid))
|
|
60
61
|
|
|
61
62
|
patron_profile = UserProfile.get_by_userid(patron_pid).__dict__
|
|
62
|
-
del patron_profile["_sa_instance_state"]
|
|
63
63
|
|
|
64
64
|
patron_data = {
|
|
65
65
|
"patron": patron,
|
|
@@ -97,9 +97,7 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
97
97
|
)
|
|
98
98
|
)
|
|
99
99
|
OrderSearch = current_ils_acq.order_search_cls
|
|
100
|
-
n_orders = (
|
|
101
|
-
OrderSearch().get_ongoing_orders_by_patron_pid(patron_pid).count()
|
|
102
|
-
)
|
|
100
|
+
n_orders = OrderSearch().get_ongoing_orders_by_patron_pid(patron_pid).count()
|
|
103
101
|
if n_orders > 0:
|
|
104
102
|
raise AnonymizationActiveLoansError(
|
|
105
103
|
"Cannot delete user {0}: found {1} active orders.".format(
|
|
@@ -111,9 +109,32 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
111
109
|
cls = current_app.config["ILS_PATRON_ANONYMOUS_CLASS"]
|
|
112
110
|
anonymous_patron_fields = cls().dumps_loader()
|
|
113
111
|
|
|
112
|
+
Loan = current_circulation.loan_record_cls
|
|
113
|
+
BorrowingRequest = current_ils_ill.borrowing_request_record_cls
|
|
114
|
+
DocumentRequest = current_app_ils.document_request_record_cls
|
|
115
|
+
Order = current_ils_acq.order_record_cls
|
|
116
|
+
|
|
117
|
+
anonymized_records = {
|
|
118
|
+
CIRCULATION_LOAN_PID_TYPE: {
|
|
119
|
+
"indexer": current_circulation.loan_indexer(),
|
|
120
|
+
"records": [],
|
|
121
|
+
},
|
|
122
|
+
BORROWING_REQUEST_PID_TYPE: {
|
|
123
|
+
"indexer": current_ils_ill.borrowing_request_indexer_cls(),
|
|
124
|
+
"records": [],
|
|
125
|
+
},
|
|
126
|
+
DOCUMENT_REQUEST_PID_TYPE: {
|
|
127
|
+
"indexer": current_app_ils.document_request_indexer,
|
|
128
|
+
"records": [],
|
|
129
|
+
},
|
|
130
|
+
ORDER_PID_TYPE: {
|
|
131
|
+
"indexer": current_ils_acq.order_indexer,
|
|
132
|
+
"records": [],
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
114
136
|
patron_loans = get_loans_by_patron_pid(patron_pid).scan()
|
|
115
137
|
|
|
116
|
-
Loan = current_circulation.loan_record_cls
|
|
117
138
|
indices = 0
|
|
118
139
|
for hit in patron_loans:
|
|
119
140
|
loan = Loan.get_record_by_pid(hit.pid)
|
|
@@ -136,7 +157,7 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
136
157
|
loan["patron_pid"] = anonymous_patron_fields["pid"]
|
|
137
158
|
loan["patron"] = anonymous_patron_fields
|
|
138
159
|
loan.commit()
|
|
139
|
-
|
|
160
|
+
anonymized_records[CIRCULATION_LOAN_PID_TYPE]["records"].append(loan)
|
|
140
161
|
indices += 1
|
|
141
162
|
|
|
142
163
|
BorrowingRequestsSearch = current_ils_ill.borrowing_request_search_cls
|
|
@@ -144,14 +165,14 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
144
165
|
BorrowingRequestsSearch().search_by_patron_pid(patron_pid).scan()
|
|
145
166
|
)
|
|
146
167
|
|
|
147
|
-
BorrowingRequest = current_ils_ill.borrowing_request_record_cls
|
|
148
|
-
indexer = current_ils_ill.borrowing_request_indexer_cls()
|
|
149
168
|
for hit in patron_borrowing_requests:
|
|
150
169
|
borrowing_request = BorrowingRequest.get_record_by_pid(hit.pid)
|
|
151
170
|
borrowing_request["patron"] = anonymous_patron_fields
|
|
152
171
|
borrowing_request["patron_pid"] = anonymous_patron_fields["pid"]
|
|
153
172
|
borrowing_request.commit()
|
|
154
|
-
|
|
173
|
+
anonymized_records[BORROWING_REQUEST_PID_TYPE]["records"].append(
|
|
174
|
+
borrowing_request
|
|
175
|
+
)
|
|
155
176
|
indices += 1
|
|
156
177
|
|
|
157
178
|
DocumentRequestSearch = current_app_ils.document_request_search_cls
|
|
@@ -159,7 +180,6 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
159
180
|
DocumentRequestSearch().search_by_patron_pid(patron_pid).scan()
|
|
160
181
|
)
|
|
161
182
|
|
|
162
|
-
DocumentRequest = current_app_ils.document_request_record_cls
|
|
163
183
|
for hit in patron_document_requests:
|
|
164
184
|
document_request = DocumentRequest.get_record_by_pid(hit.pid)
|
|
165
185
|
if document_request["state"] == "PENDING":
|
|
@@ -168,19 +188,18 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
168
188
|
document_request["patron"] = anonymous_patron_fields
|
|
169
189
|
document_request["patron_pid"] = anonymous_patron_fields["pid"]
|
|
170
190
|
document_request.commit()
|
|
171
|
-
|
|
191
|
+
anonymized_records[ORDER_PID_TYPE]["records"].append(document_request)
|
|
172
192
|
indices += 1
|
|
173
193
|
|
|
174
194
|
patron_acquisitions = OrderSearch().search_by_patron_pid(patron_pid).scan()
|
|
175
195
|
|
|
176
|
-
Order = current_ils_acq.order_record_cls
|
|
177
196
|
for hit in patron_acquisitions:
|
|
178
197
|
acquisition = Order.get_record_by_pid(hit.pid)
|
|
179
198
|
for line in acquisition["order_lines"]:
|
|
180
|
-
if line
|
|
199
|
+
if line.get("patron_pid") == patron_pid:
|
|
181
200
|
line["patron_pid"] = anonymous_patron_fields["pid"]
|
|
182
201
|
acquisition.commit()
|
|
183
|
-
|
|
202
|
+
anonymized_records[Order._pid_type]["records"].append(acquisition)
|
|
184
203
|
indices += 1
|
|
185
204
|
|
|
186
205
|
# delete rows from db
|
|
@@ -190,11 +209,18 @@ def anonymize_patron_data(patron_pid, force=False):
|
|
|
190
209
|
notifications = anonymize_patron_in_notification_logs(patron_pid)
|
|
191
210
|
|
|
192
211
|
db.session.commit()
|
|
212
|
+
|
|
213
|
+
# index all after committing to DB, to ensure that no errors occurred.
|
|
214
|
+
for value in anonymized_records.values():
|
|
215
|
+
indexer, records = value["indexer"], value["records"]
|
|
216
|
+
for record in records:
|
|
217
|
+
indexer.index(record)
|
|
218
|
+
|
|
193
219
|
if patron:
|
|
194
220
|
try:
|
|
195
221
|
patron_indexer = current_app_ils.patron_indexer
|
|
196
222
|
patron_indexer.delete(patron)
|
|
197
|
-
except NotFoundError:
|
|
223
|
+
except inv_search.NotFoundError:
|
|
198
224
|
pass
|
|
199
225
|
|
|
200
226
|
return dropped, indices, notifications
|
|
@@ -205,22 +231,16 @@ def delete_user_account(patron_pid):
|
|
|
205
231
|
dropped = 0
|
|
206
232
|
|
|
207
233
|
with db.session.begin_nested():
|
|
208
|
-
|
|
209
234
|
d = db.session.query(userrole).filter(userrole.c.user_id == patron_pid)
|
|
210
235
|
dropped += d.delete(synchronize_session=False) or 0
|
|
211
236
|
|
|
212
237
|
dropped += (
|
|
213
|
-
SessionActivity.query.filter(
|
|
214
|
-
SessionActivity.user_id == patron_pid
|
|
215
|
-
).delete()
|
|
238
|
+
SessionActivity.query.filter(SessionActivity.user_id == patron_pid).delete()
|
|
216
239
|
or 0
|
|
217
240
|
)
|
|
218
241
|
|
|
219
242
|
dropped += (
|
|
220
|
-
UserIdentity.query.filter(
|
|
221
|
-
UserIdentity.id_user == patron_pid
|
|
222
|
-
).delete()
|
|
223
|
-
or 0
|
|
243
|
+
UserIdentity.query.filter(UserIdentity.id_user == patron_pid).delete() or 0
|
|
224
244
|
)
|
|
225
245
|
|
|
226
246
|
ra = RemoteAccount.query.filter(
|
|
@@ -236,8 +256,8 @@ def delete_user_account(patron_pid):
|
|
|
236
256
|
dropped += ra.delete() or 0
|
|
237
257
|
|
|
238
258
|
dropped += (
|
|
239
|
-
|
|
240
|
-
|
|
259
|
+
LoginInformation.query.filter(
|
|
260
|
+
LoginInformation.user_id == patron_pid
|
|
241
261
|
).delete()
|
|
242
262
|
or 0
|
|
243
263
|
)
|
|
@@ -253,7 +273,8 @@ def anonymize_patron_in_notification_logs(patron_pid):
|
|
|
253
273
|
|
|
254
274
|
with db.session.begin_nested():
|
|
255
275
|
notifications = NotificationsLogs.query.filter_by(
|
|
256
|
-
recipient_user_id=patron_pid
|
|
276
|
+
recipient_user_id=patron_pid
|
|
277
|
+
).all()
|
|
257
278
|
for notification in notifications:
|
|
258
279
|
notification.recipient_user_id = AnonymousPatron.id
|
|
259
280
|
notification_anonymizations += 1
|
invenio_app_ils/patrons/api.py
CHANGED
|
@@ -13,7 +13,7 @@ from flask import current_app
|
|
|
13
13
|
from invenio_accounts.models import User
|
|
14
14
|
from invenio_pidstore.models import PIDStatus
|
|
15
15
|
from invenio_pidstore.providers.recordid_v2 import RecordIdProviderV2
|
|
16
|
-
from invenio_userprofiles.
|
|
16
|
+
from invenio_userprofiles.models import UserProfile
|
|
17
17
|
|
|
18
18
|
from invenio_app_ils.errors import PatronNotFoundError
|
|
19
19
|
from invenio_app_ils.fetchers import pid_fetcher
|
|
@@ -29,16 +29,14 @@ PatronIdProvider = type(
|
|
|
29
29
|
dict(pid_type=PATRON_PID_TYPE, default_status=PIDStatus.REGISTERED),
|
|
30
30
|
)
|
|
31
31
|
patron_pid_minter = None
|
|
32
|
-
patron_pid_fetcher = partial(
|
|
33
|
-
pid_fetcher, provider_cls=PatronIdProvider, pid_field="id"
|
|
34
|
-
)
|
|
32
|
+
patron_pid_fetcher = partial(pid_fetcher, provider_cls=PatronIdProvider, pid_field="id")
|
|
35
33
|
|
|
36
34
|
|
|
37
35
|
class Patron(dict):
|
|
38
36
|
"""Patron record class."""
|
|
39
37
|
|
|
40
38
|
_index = "patrons-patron-v1.0.0"
|
|
41
|
-
_doc_type =
|
|
39
|
+
_doc_type = None
|
|
42
40
|
# Fake schema used to identify pid type from ES hit
|
|
43
41
|
_schema = "patrons/patron-v1.0.0.json"
|
|
44
42
|
|
invenio_app_ils/patrons/cli.py
CHANGED
|
@@ -57,8 +57,7 @@ def list_activity(patron_pid):
|
|
|
57
57
|
def anonymize(patron_pid, force):
|
|
58
58
|
"""Anonymize patron's data and activity."""
|
|
59
59
|
if click.confirm("Are you sure you want to anonymize this patron?"):
|
|
60
|
-
dropped, indices, notifications =
|
|
61
|
-
anonymize_patron_data(patron_pid, force)
|
|
60
|
+
dropped, indices, notifications = anonymize_patron_data(patron_pid, force)
|
|
62
61
|
msg = (
|
|
63
62
|
"Successfully anonymized patron's activity: {dropped} rows "
|
|
64
63
|
"deleted from db, {indices} records re-indexed and "
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
from datetime import datetime
|
|
11
11
|
|
|
12
12
|
from celery import shared_task
|
|
13
|
-
from elasticsearch import VERSION as ES_VERSION
|
|
14
13
|
from flask import current_app
|
|
15
14
|
from invenio_accounts.models import User
|
|
16
15
|
from invenio_circulation.pidstore.pids import CIRCULATION_LOAN_PID_TYPE
|
|
@@ -28,8 +27,6 @@ from invenio_app_ils.indexer import ReferencedRecordsIndexer
|
|
|
28
27
|
from invenio_app_ils.patrons.api import PATRON_PID_TYPE
|
|
29
28
|
from invenio_app_ils.proxies import current_app_ils
|
|
30
29
|
|
|
31
|
-
lt_es7 = ES_VERSION[0] < 7
|
|
32
|
-
|
|
33
30
|
|
|
34
31
|
def get_loans(patron_pid):
|
|
35
32
|
"""Get referenced loans."""
|
|
@@ -37,9 +34,7 @@ def get_loans(patron_pid):
|
|
|
37
34
|
loan_record_cls = current_circulation.loan_record_cls
|
|
38
35
|
for hit in search_by_patron_pid(patron_pid=patron_pid).scan():
|
|
39
36
|
loan = loan_record_cls.get_record_by_pid(hit["pid"])
|
|
40
|
-
referenced.append(
|
|
41
|
-
dict(pid_type=CIRCULATION_LOAN_PID_TYPE, record=loan)
|
|
42
|
-
)
|
|
37
|
+
referenced.append(dict(pid_type=CIRCULATION_LOAN_PID_TYPE, record=loan))
|
|
43
38
|
return referenced
|
|
44
39
|
|
|
45
40
|
|
|
@@ -52,9 +47,7 @@ def get_document_requests(patron_pid):
|
|
|
52
47
|
docreq_search_cls().search_by_patron_pid(patron_pid=patron_pid).scan()
|
|
53
48
|
):
|
|
54
49
|
docreq = docreq_record_cls.get_record_by_pid(request["pid"])
|
|
55
|
-
referenced.append(
|
|
56
|
-
dict(pid_type=DOCUMENT_REQUEST_PID_TYPE, record=docreq)
|
|
57
|
-
)
|
|
50
|
+
referenced.append(dict(pid_type=DOCUMENT_REQUEST_PID_TYPE, record=docreq))
|
|
58
51
|
return referenced
|
|
59
52
|
|
|
60
53
|
|
|
@@ -78,9 +71,7 @@ def get_ill_borrowing_requests(patron_pid):
|
|
|
78
71
|
search = brw_req_search_cls().search_by_patron_pid(patron_pid)
|
|
79
72
|
for hit in search.scan():
|
|
80
73
|
brw_req = brw_req_record_cls.get_record_by_pid(hit["pid"])
|
|
81
|
-
referenced.append(
|
|
82
|
-
dict(pid_type=BORROWING_REQUEST_PID_TYPE, record=brw_req)
|
|
83
|
-
)
|
|
74
|
+
referenced.append(dict(pid_type=BORROWING_REQUEST_PID_TYPE, record=brw_req))
|
|
84
75
|
return referenced
|
|
85
76
|
|
|
86
77
|
|
|
@@ -119,7 +110,7 @@ class PatronBaseIndexer(RecordIndexer):
|
|
|
119
110
|
:param record: The record where to look for the information.
|
|
120
111
|
:returns: A tuple (index, doc_type).
|
|
121
112
|
"""
|
|
122
|
-
doc_type =
|
|
113
|
+
doc_type = None
|
|
123
114
|
return record._index, doc_type
|
|
124
115
|
|
|
125
116
|
def index_by_id(self, record_uuid, **kwargs):
|