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
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test acquisition orders."""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
|
|
12
|
-
from flask import url_for
|
|
13
|
-
|
|
14
|
-
from tests.helpers import user_login
|
|
15
|
-
|
|
16
|
-
_HTTP_OK = [200, 201, 204]
|
|
17
|
-
ORDER_PID = "acqoid-1"
|
|
18
|
-
ITEM_ENDPOINT = "invenio_records_rest.acqoid_item"
|
|
19
|
-
LIST_ENDPOINT = "invenio_records_rest.acqoid_list"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def test_acq_orders_permissions(client, testdata, json_headers, users):
|
|
23
|
-
"""Test orders endpoints permissions."""
|
|
24
|
-
dummy_acquisition_order = dict(
|
|
25
|
-
status="PENDING",
|
|
26
|
-
order_date="2020-02-25",
|
|
27
|
-
provider_pid="acq-provid-1",
|
|
28
|
-
order_lines=[
|
|
29
|
-
dict(
|
|
30
|
-
copies_ordered=3,
|
|
31
|
-
document_pid="docid-1",
|
|
32
|
-
medium="paper",
|
|
33
|
-
recipient="library",
|
|
34
|
-
)
|
|
35
|
-
],
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
def _test_list(expected_status):
|
|
39
|
-
"""Test get list."""
|
|
40
|
-
url = url_for(LIST_ENDPOINT)
|
|
41
|
-
res = client.get(url, headers=json_headers)
|
|
42
|
-
assert res.status_code in expected_status
|
|
43
|
-
|
|
44
|
-
def _test_create(expected_status, data, user):
|
|
45
|
-
"""Test record creation."""
|
|
46
|
-
url = url_for(LIST_ENDPOINT)
|
|
47
|
-
res = client.post(url, headers=json_headers, data=json.dumps(data))
|
|
48
|
-
assert res.status_code in expected_status
|
|
49
|
-
|
|
50
|
-
if res.status_code < 400:
|
|
51
|
-
ord = res.get_json()["metadata"]
|
|
52
|
-
assert ord["status"] == "PENDING"
|
|
53
|
-
expected_created_by = dict(type="user_id", value=str(user.id))
|
|
54
|
-
assert ord["created_by"] == expected_created_by
|
|
55
|
-
assert not ord.get("updated_by")
|
|
56
|
-
return ord["pid"]
|
|
57
|
-
|
|
58
|
-
def _test_update(expected_status, data, pid, user):
|
|
59
|
-
"""Test record update."""
|
|
60
|
-
pid_value = pid or ORDER_PID
|
|
61
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
62
|
-
res = client.put(url, headers=json_headers, data=json.dumps(data))
|
|
63
|
-
assert res.status_code in expected_status
|
|
64
|
-
if res.status_code < 400:
|
|
65
|
-
expected_changed_by = dict(type="user_id", value=str(user.id))
|
|
66
|
-
ord = res.get_json()["metadata"]
|
|
67
|
-
assert ord["created_by"] == expected_changed_by
|
|
68
|
-
assert ord["updated_by"] == expected_changed_by
|
|
69
|
-
|
|
70
|
-
def _test_read(expected_status, pid):
|
|
71
|
-
"""Test record read."""
|
|
72
|
-
pid_value = pid or ORDER_PID
|
|
73
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
74
|
-
res = client.get(url, headers=json_headers)
|
|
75
|
-
assert res.status_code in expected_status
|
|
76
|
-
|
|
77
|
-
def _test_delete(expected_status, pid):
|
|
78
|
-
"""Test record delete."""
|
|
79
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid)
|
|
80
|
-
res = client.delete(url, headers=json_headers)
|
|
81
|
-
assert res.status_code in expected_status
|
|
82
|
-
|
|
83
|
-
tests = [
|
|
84
|
-
("admin", _HTTP_OK, dummy_acquisition_order),
|
|
85
|
-
("librarian", _HTTP_OK, dummy_acquisition_order),
|
|
86
|
-
("patron1", [403], dummy_acquisition_order),
|
|
87
|
-
("anonymous", [401], dummy_acquisition_order),
|
|
88
|
-
]
|
|
89
|
-
for username, expected_status, data in tests:
|
|
90
|
-
user = user_login(client, username, users)
|
|
91
|
-
_test_list(expected_status)
|
|
92
|
-
pid = _test_create(expected_status, data, user)
|
|
93
|
-
_test_update(expected_status, data, pid, user)
|
|
94
|
-
_test_read(expected_status, pid)
|
|
95
|
-
|
|
96
|
-
tests = [
|
|
97
|
-
("patron1", [403]),
|
|
98
|
-
("anonymous", [401]),
|
|
99
|
-
("librarian", [403]),
|
|
100
|
-
("admin", [204]),
|
|
101
|
-
]
|
|
102
|
-
for username, expected_status in tests:
|
|
103
|
-
user_login(client, username, users)
|
|
104
|
-
_test_delete(expected_status, ORDER_PID)
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test acquisition provider."""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
|
|
12
|
-
from flask import url_for
|
|
13
|
-
|
|
14
|
-
from tests.helpers import user_login
|
|
15
|
-
|
|
16
|
-
_HTTP_OK = [200, 201, 204]
|
|
17
|
-
PROVIDER_PID = "acq-provid-1"
|
|
18
|
-
PROVIDER_NAME = "A provider"
|
|
19
|
-
PROVIDER_TYPE = "VENDOR"
|
|
20
|
-
ITEM_ENDPOINT = "invenio_records_rest.provid_item"
|
|
21
|
-
LIST_ENDPOINT = "invenio_records_rest.provid_list"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def test_acq_providers_permissions(client, testdata, json_headers, users):
|
|
25
|
-
"""Test providers endpoints permissions."""
|
|
26
|
-
dummy_acquisition_provider = dict(name=PROVIDER_NAME, type=PROVIDER_TYPE)
|
|
27
|
-
tests = [
|
|
28
|
-
("admin", _HTTP_OK, dummy_acquisition_provider),
|
|
29
|
-
("librarian", _HTTP_OK, dummy_acquisition_provider),
|
|
30
|
-
("patron1", [403], dummy_acquisition_provider),
|
|
31
|
-
("anonymous", [401], dummy_acquisition_provider),
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
def _test_list(expected_status):
|
|
35
|
-
"""Test get list."""
|
|
36
|
-
url = url_for(LIST_ENDPOINT)
|
|
37
|
-
res = client.get(url, headers=json_headers)
|
|
38
|
-
assert res.status_code in expected_status
|
|
39
|
-
|
|
40
|
-
def _test_create(expected_status, data):
|
|
41
|
-
"""Test record creation."""
|
|
42
|
-
url = url_for(LIST_ENDPOINT)
|
|
43
|
-
print("DICT", json.dumps(data))
|
|
44
|
-
res = client.post(url, headers=json_headers, data=json.dumps(data))
|
|
45
|
-
assert res.status_code in expected_status
|
|
46
|
-
|
|
47
|
-
if res.status_code < 400:
|
|
48
|
-
record = res.get_json()["metadata"]
|
|
49
|
-
assert record["name"] == PROVIDER_NAME
|
|
50
|
-
assert record["type"] == PROVIDER_TYPE
|
|
51
|
-
return record["pid"]
|
|
52
|
-
|
|
53
|
-
def _test_update(expected_status, data, pid):
|
|
54
|
-
"""Test record update."""
|
|
55
|
-
pid_value = pid or PROVIDER_PID
|
|
56
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
57
|
-
res = client.put(url, headers=json_headers, data=json.dumps(data))
|
|
58
|
-
assert res.status_code in expected_status
|
|
59
|
-
if res.status_code < 400:
|
|
60
|
-
record = res.get_json()["metadata"]
|
|
61
|
-
assert record["name"] == PROVIDER_NAME
|
|
62
|
-
|
|
63
|
-
def _test_read(expected_status, pid):
|
|
64
|
-
"""Test record read."""
|
|
65
|
-
pid_value = pid or PROVIDER_PID
|
|
66
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
67
|
-
res = client.get(url, headers=json_headers)
|
|
68
|
-
assert res.status_code in expected_status
|
|
69
|
-
|
|
70
|
-
def _test_delete(expected_status, pid):
|
|
71
|
-
"""Test record delete."""
|
|
72
|
-
pid_value = pid or PROVIDER_PID
|
|
73
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
74
|
-
res = client.delete(url, headers=json_headers)
|
|
75
|
-
assert res.status_code in expected_status
|
|
76
|
-
|
|
77
|
-
for username, expected_status, data in tests:
|
|
78
|
-
user_login(client, username, users)
|
|
79
|
-
_test_list(expected_status)
|
|
80
|
-
pid = _test_create(expected_status, data)
|
|
81
|
-
_test_update(expected_status, data, pid)
|
|
82
|
-
_test_read(expected_status, pid)
|
|
83
|
-
_test_delete(expected_status, pid)
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test transitions on expiring loans."""
|
|
9
|
-
|
|
10
|
-
from datetime import timedelta
|
|
11
|
-
|
|
12
|
-
import arrow
|
|
13
|
-
from flask import url_for
|
|
14
|
-
from invenio_indexer.api import RecordIndexer
|
|
15
|
-
from invenio_search import current_search
|
|
16
|
-
|
|
17
|
-
from invenio_app_ils.circulation.tasks import cancel_expired_loan_requests
|
|
18
|
-
from invenio_app_ils.patrons.api import SystemAgent
|
|
19
|
-
from tests.helpers import user_login
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def test_cancel_expired_loans(client, json_headers, db, users, testdata):
|
|
23
|
-
"""Test cancellation of loan requests after expiration date."""
|
|
24
|
-
|
|
25
|
-
user_login(client, "admin", users)
|
|
26
|
-
|
|
27
|
-
def prepare_data():
|
|
28
|
-
"""Prepare data."""
|
|
29
|
-
loans = testdata["loans"]
|
|
30
|
-
|
|
31
|
-
recs = []
|
|
32
|
-
now = arrow.utcnow()
|
|
33
|
-
|
|
34
|
-
def new_expiration_date(loan, date):
|
|
35
|
-
loan["request_expire_date"] = date.date().isoformat()
|
|
36
|
-
loan["state"] = "PENDING"
|
|
37
|
-
loan.commit()
|
|
38
|
-
recs.append(loan)
|
|
39
|
-
|
|
40
|
-
# expired loans
|
|
41
|
-
date = now - timedelta(days=1)
|
|
42
|
-
new_expiration_date(loans[0], date)
|
|
43
|
-
new_expiration_date(loans[1], date)
|
|
44
|
-
date = now - timedelta(days=2)
|
|
45
|
-
new_expiration_date(loans[2], date)
|
|
46
|
-
expired_pids = [loans[0]["pid"], loans[1]["pid"], loans[2]["pid"]]
|
|
47
|
-
|
|
48
|
-
# not expired loans
|
|
49
|
-
not_expired_pids = []
|
|
50
|
-
remaining_not_expired = loans[3:]
|
|
51
|
-
n_days = 0 # today
|
|
52
|
-
for loan in remaining_not_expired:
|
|
53
|
-
date = now + timedelta(days=n_days)
|
|
54
|
-
new_expiration_date(loan, date)
|
|
55
|
-
not_expired_pids.append(loan["pid"])
|
|
56
|
-
n_days += 1
|
|
57
|
-
db.session.commit()
|
|
58
|
-
|
|
59
|
-
indexer = RecordIndexer()
|
|
60
|
-
for rec in recs:
|
|
61
|
-
indexer.index(rec)
|
|
62
|
-
|
|
63
|
-
current_search.flush_and_refresh(index="*")
|
|
64
|
-
return expired_pids, not_expired_pids
|
|
65
|
-
|
|
66
|
-
expired_pids, not_expired_pids = prepare_data()
|
|
67
|
-
|
|
68
|
-
# trigger cancel expired loan requests
|
|
69
|
-
cancel_expired_loan_requests.apply_async()
|
|
70
|
-
|
|
71
|
-
for pid_value in expired_pids:
|
|
72
|
-
res = client.get(
|
|
73
|
-
url_for("invenio_records_rest.loanid_item", pid_value=pid_value),
|
|
74
|
-
headers=json_headers,
|
|
75
|
-
)
|
|
76
|
-
loan = res.get_json()["metadata"]
|
|
77
|
-
assert loan["state"] == "CANCELLED"
|
|
78
|
-
assert "cancel_reason" in loan
|
|
79
|
-
assert loan["transaction_user_pid"] == str(SystemAgent.id)
|
|
80
|
-
|
|
81
|
-
for pid_value in not_expired_pids:
|
|
82
|
-
res = client.get(
|
|
83
|
-
url_for("invenio_records_rest.loanid_item", pid_value=pid_value),
|
|
84
|
-
headers=json_headers,
|
|
85
|
-
)
|
|
86
|
-
loan = res.get_json()["metadata"]
|
|
87
|
-
assert loan["state"] == "PENDING"
|
|
88
|
-
assert "cancel_reason" not in loan
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2018-2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test loans item permissions."""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
from copy import deepcopy
|
|
12
|
-
from datetime import timedelta
|
|
13
|
-
|
|
14
|
-
import arrow
|
|
15
|
-
from flask import url_for
|
|
16
|
-
from flask_principal import UserNeed
|
|
17
|
-
from invenio_access.permissions import Permission
|
|
18
|
-
|
|
19
|
-
from invenio_app_ils.items.api import Item
|
|
20
|
-
from tests.helpers import user_login
|
|
21
|
-
|
|
22
|
-
NEW_LOAN = {
|
|
23
|
-
"item_pid": "CHANGE ME IN EACH TEST",
|
|
24
|
-
"document_pid": "docid-1",
|
|
25
|
-
"patron_pid": "3",
|
|
26
|
-
"transaction_location_pid": "locid-1",
|
|
27
|
-
"pickup_location_pid": "locid-1",
|
|
28
|
-
"delivery": {"method": "PICK_UP"},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_anonymous_cannot_request_loan_on_item(client, json_headers, testdata):
|
|
33
|
-
"""Test that anonymous users cannot request a loan on a item."""
|
|
34
|
-
url = url_for("invenio_app_ils_circulation.loan_checkout")
|
|
35
|
-
res = client.post(url, headers=json_headers, data=json.dumps(NEW_LOAN))
|
|
36
|
-
assert res.status_code == 401
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def test_librarian_can_checkout_item_for_user(
|
|
40
|
-
client, json_headers, users, testdata
|
|
41
|
-
):
|
|
42
|
-
"""Test that librarian can checkout a loan on a item for a patron."""
|
|
43
|
-
user_login(client, "librarian", users)
|
|
44
|
-
url = url_for("invenio_app_ils_circulation.loan_checkout")
|
|
45
|
-
params = deepcopy(NEW_LOAN)
|
|
46
|
-
params["transaction_user_pid"] = str(users["librarian"].id)
|
|
47
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-60")
|
|
48
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
49
|
-
assert res.status_code == 202
|
|
50
|
-
loan = res.get_json()["metadata"]
|
|
51
|
-
assert loan["state"] == "ITEM_ON_LOAN"
|
|
52
|
-
assert loan["item_pid"] == params["item_pid"]
|
|
53
|
-
assert loan["document_pid"] == params["document_pid"]
|
|
54
|
-
assert loan["patron_pid"] == params["patron_pid"]
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def test_force_checkout_specific_permissions(
|
|
58
|
-
app, client, json_headers, users, testdata
|
|
59
|
-
):
|
|
60
|
-
"""Test that only allowed users can perform a force checkout."""
|
|
61
|
-
default_factory = app.config["ILS_VIEWS_PERMISSIONS_FACTORY"]
|
|
62
|
-
librarian2 = users["librarian2"]
|
|
63
|
-
|
|
64
|
-
# override default permission factory to require specific permission for
|
|
65
|
-
# force-checkout action
|
|
66
|
-
def custom_views_permissions_factory(action):
|
|
67
|
-
if action == "circulation-loan-force-checkout":
|
|
68
|
-
# fake permission for a specific user
|
|
69
|
-
return Permission(UserNeed(librarian2.id))
|
|
70
|
-
else:
|
|
71
|
-
return default_factory(action)
|
|
72
|
-
|
|
73
|
-
app.config[
|
|
74
|
-
"ILS_VIEWS_PERMISSIONS_FACTORY"
|
|
75
|
-
] = custom_views_permissions_factory
|
|
76
|
-
|
|
77
|
-
# prepare request
|
|
78
|
-
url = url_for("invenio_app_ils_circulation.loan_checkout")
|
|
79
|
-
params = deepcopy(NEW_LOAN)
|
|
80
|
-
params["force"] = True
|
|
81
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-MISSING")
|
|
82
|
-
params["transaction_user_pid"] = str(librarian2.id)
|
|
83
|
-
|
|
84
|
-
# force-checkout as librarian should fail
|
|
85
|
-
user_login(client, "librarian", users)
|
|
86
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
87
|
-
assert res.status_code == 403
|
|
88
|
-
|
|
89
|
-
# force-checkout as librarian2 should succeed
|
|
90
|
-
user_login(client, "librarian2", users)
|
|
91
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
92
|
-
assert res.status_code == 202
|
|
93
|
-
loan = res.get_json()["metadata"]
|
|
94
|
-
assert loan["state"] == "ITEM_ON_LOAN"
|
|
95
|
-
assert loan["item_pid"] == params["item_pid"]
|
|
96
|
-
assert loan["document_pid"] == params["document_pid"]
|
|
97
|
-
assert loan["patron_pid"] == params["patron_pid"]
|
|
98
|
-
|
|
99
|
-
# restore default config
|
|
100
|
-
app.config["ILS_VIEWS_PERMISSIONS_FACTORY"] = default_factory
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def test_checkout_conditions_librarian(client, json_headers, users, testdata):
|
|
104
|
-
"""Test checkout conditions user."""
|
|
105
|
-
librarian = users["librarian"]
|
|
106
|
-
user_login(client, "librarian", users)
|
|
107
|
-
url = url_for("invenio_app_ils_circulation.loan_checkout")
|
|
108
|
-
|
|
109
|
-
params = deepcopy(NEW_LOAN)
|
|
110
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-61")
|
|
111
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
112
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
113
|
-
assert res.status_code == 202
|
|
114
|
-
|
|
115
|
-
params = deepcopy(NEW_LOAN)
|
|
116
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-MISSING")
|
|
117
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
118
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
119
|
-
# missing
|
|
120
|
-
assert res.status_code == 400
|
|
121
|
-
|
|
122
|
-
params = deepcopy(NEW_LOAN)
|
|
123
|
-
params["force"] = True
|
|
124
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-MISSING")
|
|
125
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
126
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
127
|
-
# missing but force
|
|
128
|
-
assert res.status_code == 202
|
|
129
|
-
item = Item.get_record_by_pid(params["item_pid"]["value"])
|
|
130
|
-
assert item["status"] == "CAN_CIRCULATE"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def test_checkout_loader_start_end_dates(
|
|
134
|
-
app, client, json_headers, users, testdata
|
|
135
|
-
):
|
|
136
|
-
"""Test that start and end dates request parameters."""
|
|
137
|
-
librarian = users["librarian"]
|
|
138
|
-
user_login(client, "librarian", users)
|
|
139
|
-
item_pid = dict(type="pitmid", value="itemid-61")
|
|
140
|
-
url = url_for("invenio_app_ils_circulation.loan_checkout")
|
|
141
|
-
# fake duration for first item
|
|
142
|
-
loan_duration_timedelta = app.config["CIRCULATION_POLICIES"]["checkout"][
|
|
143
|
-
"duration_default"
|
|
144
|
-
](dict(item_pid=item_pid), dict())
|
|
145
|
-
now = arrow.utcnow()
|
|
146
|
-
|
|
147
|
-
# it should succeed when no start/end dates provided
|
|
148
|
-
start_date = now.date().isoformat()
|
|
149
|
-
end_date = (now + loan_duration_timedelta).date().isoformat()
|
|
150
|
-
|
|
151
|
-
params = deepcopy(NEW_LOAN)
|
|
152
|
-
params["item_pid"] = item_pid
|
|
153
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
154
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
155
|
-
assert res.status_code == 202
|
|
156
|
-
loan = res.get_json()["metadata"]
|
|
157
|
-
assert loan["state"] == "ITEM_ON_LOAN"
|
|
158
|
-
assert loan["item_pid"] == params["item_pid"]
|
|
159
|
-
assert loan["start_date"] == start_date
|
|
160
|
-
assert loan["end_date"] == end_date
|
|
161
|
-
assert loan["transaction_date"]
|
|
162
|
-
|
|
163
|
-
# it should succeed when no end date provided
|
|
164
|
-
_start_date = now + timedelta(days=3)
|
|
165
|
-
start_date = _start_date.date().isoformat()
|
|
166
|
-
end_date = (_start_date + loan_duration_timedelta).date().isoformat()
|
|
167
|
-
|
|
168
|
-
params = deepcopy(NEW_LOAN)
|
|
169
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-62")
|
|
170
|
-
params["start_date"] = start_date
|
|
171
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
172
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
173
|
-
assert res.status_code == 202
|
|
174
|
-
loan = res.get_json()["metadata"]
|
|
175
|
-
assert loan["state"] == "ITEM_ON_LOAN"
|
|
176
|
-
assert loan["item_pid"] == params["item_pid"]
|
|
177
|
-
assert loan["start_date"] == start_date
|
|
178
|
-
assert loan["end_date"] == end_date
|
|
179
|
-
assert loan["transaction_date"]
|
|
180
|
-
|
|
181
|
-
start_date = (now + timedelta(days=3)).date().isoformat()
|
|
182
|
-
end_date = (now + timedelta(days=15)).date().isoformat()
|
|
183
|
-
|
|
184
|
-
# it should succeed when start/end dates provided
|
|
185
|
-
params = deepcopy(NEW_LOAN)
|
|
186
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-63")
|
|
187
|
-
params["start_date"] = start_date
|
|
188
|
-
params["end_date"] = end_date
|
|
189
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
190
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
191
|
-
assert res.status_code == 202
|
|
192
|
-
loan = res.get_json()["metadata"]
|
|
193
|
-
assert loan["state"] == "ITEM_ON_LOAN"
|
|
194
|
-
assert loan["item_pid"] == params["item_pid"]
|
|
195
|
-
assert loan["start_date"] == start_date
|
|
196
|
-
assert loan["end_date"] == end_date
|
|
197
|
-
assert loan["transaction_date"]
|
|
198
|
-
|
|
199
|
-
# it should fail when only end date provided
|
|
200
|
-
params = deepcopy(NEW_LOAN)
|
|
201
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-63")
|
|
202
|
-
params["end_date"] = end_date
|
|
203
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
204
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
205
|
-
assert res.status_code == 400
|
|
206
|
-
|
|
207
|
-
# it should fail when wrong date provided
|
|
208
|
-
start_date = (now + timedelta(days=3)).date().isoformat()
|
|
209
|
-
past_end_date = now - timedelta(days=30)
|
|
210
|
-
params = deepcopy(NEW_LOAN)
|
|
211
|
-
params["item_pid"] = dict(type="pitmid", value="itemid-63")
|
|
212
|
-
params["start_date"] = start_date
|
|
213
|
-
params["end_date"] = past_end_date.date().isoformat()
|
|
214
|
-
params["transaction_user_pid"] = str(librarian.id)
|
|
215
|
-
res = client.post(url, headers=json_headers, data=json.dumps(params))
|
|
216
|
-
assert res.status_code == 400
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test loans default durations."""
|
|
9
|
-
|
|
10
|
-
from datetime import timedelta
|
|
11
|
-
|
|
12
|
-
import arrow
|
|
13
|
-
|
|
14
|
-
from invenio_app_ils.ill.api import (
|
|
15
|
-
circulation_default_extension_duration,
|
|
16
|
-
circulation_default_loan_duration,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
FAKE_LOAN_ITEM_NO_RESTRICTIONS = {
|
|
20
|
-
"item_pid": {"type": "pitmid", "value": "itemid-1"}
|
|
21
|
-
}
|
|
22
|
-
FAKE_LOAN_ITEM_ONE_WEEK = {"item_pid": {"type": "pitmid", "value": "itemid-2"}}
|
|
23
|
-
FAKE_LOAN_ITEM_TWO_WEEKS = {
|
|
24
|
-
"item_pid": {"type": "pitmid", "value": "itemid-3"}
|
|
25
|
-
}
|
|
26
|
-
FAKE_LOAN_ITEM_THREE_WEEKS = {
|
|
27
|
-
"item_pid": {"type": "pitmid", "value": "itemid-4"}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_loans_default_durations(testdata):
|
|
32
|
-
"""Test loans default durations."""
|
|
33
|
-
tomorrow = arrow.utcnow() + timedelta(days=1)
|
|
34
|
-
not_overdue_end_date = tomorrow.date().isoformat()
|
|
35
|
-
for duration_func in (
|
|
36
|
-
circulation_default_loan_duration,
|
|
37
|
-
circulation_default_extension_duration,
|
|
38
|
-
):
|
|
39
|
-
FAKE_LOAN_ITEM_NO_RESTRICTIONS["end_date"] = not_overdue_end_date
|
|
40
|
-
assert duration_func(
|
|
41
|
-
FAKE_LOAN_ITEM_NO_RESTRICTIONS, None
|
|
42
|
-
) == timedelta(weeks=4)
|
|
43
|
-
|
|
44
|
-
FAKE_LOAN_ITEM_ONE_WEEK["end_date"] = not_overdue_end_date
|
|
45
|
-
assert duration_func(FAKE_LOAN_ITEM_ONE_WEEK, None) == timedelta(
|
|
46
|
-
weeks=1
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
FAKE_LOAN_ITEM_TWO_WEEKS["end_date"] = not_overdue_end_date
|
|
50
|
-
assert duration_func(FAKE_LOAN_ITEM_TWO_WEEKS, None) == timedelta(
|
|
51
|
-
weeks=2
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
FAKE_LOAN_ITEM_THREE_WEEKS["end_date"] = not_overdue_end_date
|
|
55
|
-
assert duration_func(FAKE_LOAN_ITEM_THREE_WEEKS, None) == timedelta(
|
|
56
|
-
weeks=3
|
|
57
|
-
)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2019 CERN.
|
|
4
|
-
#
|
|
5
|
-
# Invenio-Circulation is free software; you can redistribute it and/or modify
|
|
6
|
-
# it under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Tests for loan item resolver."""
|
|
9
|
-
|
|
10
|
-
from invenio_circulation.api import Loan
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_loan_document_resolver(app, testdata):
|
|
14
|
-
"""Test item resolving from loan."""
|
|
15
|
-
loan_pid = testdata["loans"][1]["pid"]
|
|
16
|
-
loan = Loan.get_record_by_pid(loan_pid)
|
|
17
|
-
loan = loan.replace_refs()
|
|
18
|
-
assert loan["document"]["pid"] == loan["document_pid"]
|