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.
Files changed (331) hide show
  1. invenio_app_ils/__init__.py +2 -2
  2. invenio_app_ils/acquisition/api.py +3 -1
  3. invenio_app_ils/acquisition/config.py +10 -21
  4. invenio_app_ils/acquisition/jsonresolvers/order_order_lines.py +1 -0
  5. invenio_app_ils/acquisition/mappings/os-v1/acq_orders/order-v1.0.0.json +364 -0
  6. invenio_app_ils/acquisition/mappings/os-v2/__init__.py +0 -0
  7. invenio_app_ils/acquisition/mappings/os-v2/acq_orders/order-v1.0.0.json +364 -0
  8. invenio_app_ils/acquisition/mappings/v7/acq_orders/order-v1.0.0.json +14 -0
  9. invenio_app_ils/acquisition/search.py +5 -15
  10. invenio_app_ils/assets/semantic-ui/less/theme.config +103 -0
  11. invenio_app_ils/assets/semantic-ui/templates/.gitkeep +0 -0
  12. invenio_app_ils/circulation/api.py +153 -67
  13. invenio_app_ils/circulation/config.py +29 -25
  14. invenio_app_ils/circulation/indexer.py +14 -19
  15. invenio_app_ils/circulation/loaders/__init__.py +2 -0
  16. invenio_app_ils/circulation/loaders/schemas/json/loan_checkout.py +2 -3
  17. invenio_app_ils/circulation/loaders/schemas/json/loan_request.py +82 -16
  18. invenio_app_ils/circulation/loaders/schemas/json/loan_self_checkout.py +19 -0
  19. invenio_app_ils/circulation/notifications/api.py +23 -19
  20. invenio_app_ils/circulation/notifications/messages.py +6 -6
  21. invenio_app_ils/circulation/notifications/tasks.py +1 -2
  22. invenio_app_ils/circulation/receivers.py +2 -5
  23. invenio_app_ils/circulation/search.py +23 -22
  24. invenio_app_ils/circulation/serializers/__init__.py +2 -2
  25. invenio_app_ils/circulation/serializers/csv.py +1 -3
  26. invenio_app_ils/circulation/serializers/custom_fields.py +5 -9
  27. invenio_app_ils/circulation/serializers/json.py +2 -6
  28. invenio_app_ils/circulation/serializers/response.py +12 -12
  29. invenio_app_ils/circulation/stats/views.py +5 -15
  30. invenio_app_ils/circulation/tasks.py +2 -6
  31. invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/self_checkout.html +19 -0
  32. invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/update_dates.html +19 -0
  33. invenio_app_ils/circulation/utils.py +23 -17
  34. invenio_app_ils/circulation/views.py +103 -39
  35. invenio_app_ils/cli.py +220 -260
  36. invenio_app_ils/closures/api.py +72 -7
  37. invenio_app_ils/closures/serializers/__init__.py +16 -0
  38. invenio_app_ils/closures/serializers/response.py +35 -0
  39. invenio_app_ils/closures/serializers/schema.py +28 -0
  40. invenio_app_ils/closures/tasks.py +4 -11
  41. invenio_app_ils/closures/views.py +66 -0
  42. invenio_app_ils/config.py +207 -150
  43. invenio_app_ils/document_requests/api.py +6 -21
  44. invenio_app_ils/document_requests/loaders/__init__.py +4 -12
  45. invenio_app_ils/document_requests/mappings/{v6 → os-v1}/__init__.py +2 -2
  46. invenio_app_ils/document_requests/mappings/os-v1/document_requests/document_request-v1.0.0.json +196 -0
  47. invenio_app_ils/document_requests/mappings/os-v2/__init__.py +8 -0
  48. invenio_app_ils/document_requests/mappings/os-v2/document_requests/document_request-v1.0.0.json +196 -0
  49. invenio_app_ils/document_requests/notifications/api.py +2 -7
  50. invenio_app_ils/document_requests/notifications/messages.py +3 -7
  51. invenio_app_ils/document_requests/search.py +2 -6
  52. invenio_app_ils/document_requests/views.py +4 -10
  53. invenio_app_ils/documents/api.py +19 -25
  54. invenio_app_ils/documents/indexer.py +13 -20
  55. invenio_app_ils/documents/jsonresolvers/document_circulation.py +11 -33
  56. invenio_app_ils/documents/jsonresolvers/document_eitem.py +1 -0
  57. invenio_app_ils/documents/jsonresolvers/document_item.py +8 -9
  58. invenio_app_ils/documents/jsonresolvers/document_stock.py +7 -7
  59. invenio_app_ils/documents/loaders/jsonschemas/document.py +3 -14
  60. invenio_app_ils/documents/mappings/{v6 → os-v1}/__init__.py +1 -1
  61. invenio_app_ils/documents/mappings/os-v1/documents/document-v1.0.0.json +932 -0
  62. invenio_app_ils/documents/mappings/os-v1/documents/document-v2.0.0.json +1066 -0
  63. invenio_app_ils/documents/mappings/os-v2/__init__.py +8 -0
  64. invenio_app_ils/documents/mappings/os-v2/documents/document-v1.0.0.json +932 -0
  65. invenio_app_ils/documents/mappings/os-v2/documents/document-v2.0.0.json +1066 -0
  66. invenio_app_ils/documents/mappings/v7/documents/document-v1.0.0.json +102 -11
  67. invenio_app_ils/documents/mappings/v7/documents/document-v2.0.0.json +1066 -0
  68. invenio_app_ils/documents/schemas/documents/document-v2.0.0.json +732 -0
  69. invenio_app_ils/eitems/api.py +41 -7
  70. invenio_app_ils/eitems/loaders/jsonschemas/eitems.py +6 -6
  71. invenio_app_ils/eitems/mappings/{v6 → os-v1}/__init__.py +1 -1
  72. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v1.0.0.json +139 -0
  73. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v2.0.0.json +142 -0
  74. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v3.0.0.json +179 -0
  75. invenio_app_ils/{series/mappings/v6 → eitems/mappings/os-v2}/__init__.py +1 -1
  76. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v1.0.0.json +139 -0
  77. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v2.0.0.json +142 -0
  78. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v3.0.0.json +179 -0
  79. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v1.0.0.json +12 -2
  80. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v2.0.0.json +142 -0
  81. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v3.0.0.json +179 -0
  82. invenio_app_ils/eitems/schemas/eitems/eitem-v2.0.0.json +120 -0
  83. invenio_app_ils/eitems/schemas/eitems/eitem-v3.0.0.json +120 -0
  84. invenio_app_ils/eitems/search.py +3 -9
  85. invenio_app_ils/errors.py +119 -6
  86. invenio_app_ils/ext.py +15 -18
  87. invenio_app_ils/facets.py +13 -15
  88. invenio_app_ils/files/receivers.py +1 -1
  89. invenio_app_ils/files/views.py +1 -2
  90. invenio_app_ils/ill/api.py +1 -2
  91. invenio_app_ils/ill/config.py +10 -16
  92. invenio_app_ils/ill/jsonresolvers/borrowing_request_document.py +2 -3
  93. invenio_app_ils/ill/jsonresolvers/borrowing_request_patron.py +1 -3
  94. invenio_app_ils/ill/jsonresolvers/borrowing_request_provider.py +1 -3
  95. invenio_app_ils/ill/loaders/__init__.py +3 -9
  96. invenio_app_ils/ill/loaders/jsonschemas/patron_loan_actions.py +1 -8
  97. invenio_app_ils/ill/loaders/jsonschemas/patron_loan_extension_actions.py +3 -8
  98. invenio_app_ils/ill/mappings/{v6 → os-v1}/__init__.py +1 -1
  99. invenio_app_ils/ill/mappings/os-v1/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
  100. invenio_app_ils/{acquisition/mappings/v6 → ill/mappings/os-v2}/__init__.py +1 -1
  101. invenio_app_ils/ill/mappings/os-v2/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
  102. invenio_app_ils/ill/mappings/v7/ill_borrowing_requests/borrowing_request-v1.0.0.json +14 -0
  103. invenio_app_ils/ill/notifications/api.py +1 -4
  104. invenio_app_ils/ill/search.py +3 -9
  105. invenio_app_ils/ill/serializers/__init__.py +1 -3
  106. invenio_app_ils/ill/views.py +2 -4
  107. invenio_app_ils/internal_locations/api.py +1 -4
  108. invenio_app_ils/internal_locations/mappings/{v6 → os-v1}/__init__.py +1 -1
  109. invenio_app_ils/internal_locations/mappings/os-v1/internal_locations/internal_location-v1.0.0.json +108 -0
  110. invenio_app_ils/internal_locations/mappings/os-v2/__init__.py +8 -0
  111. invenio_app_ils/internal_locations/mappings/os-v2/internal_locations/internal_location-v1.0.0.json +108 -0
  112. invenio_app_ils/internal_locations/search.py +1 -3
  113. invenio_app_ils/items/api.py +18 -15
  114. invenio_app_ils/items/indexer.py +1 -3
  115. invenio_app_ils/items/jsonresolvers/item_document.py +1 -1
  116. invenio_app_ils/items/jsonresolvers/item_internal_location.py +2 -6
  117. invenio_app_ils/items/loaders/jsonschemas/items.py +2 -0
  118. {tests/api/circulation → invenio_app_ils/items/mappings/os-v1}/__init__.py +1 -1
  119. invenio_app_ils/items/mappings/os-v1/items/item-v1.0.0.json +285 -0
  120. invenio_app_ils/items/mappings/os-v1/items/item-v2.0.0.json +326 -0
  121. {tests/api/ill → invenio_app_ils/items/mappings/os-v2}/__init__.py +1 -1
  122. invenio_app_ils/items/mappings/os-v2/items/item-v1.0.0.json +285 -0
  123. invenio_app_ils/items/mappings/os-v2/items/item-v2.0.0.json +326 -0
  124. invenio_app_ils/items/mappings/v7/items/item-v1.0.0.json +11 -0
  125. invenio_app_ils/items/mappings/v7/items/item-v2.0.0.json +326 -0
  126. invenio_app_ils/items/schemas/items/item-v1.0.0.json +22 -0
  127. invenio_app_ils/items/schemas/items/item-v2.0.0.json +172 -0
  128. invenio_app_ils/items/search.py +18 -11
  129. invenio_app_ils/items/serializers/item.py +7 -6
  130. invenio_app_ils/literature/api.py +1 -3
  131. invenio_app_ils/literature/search.py +3 -5
  132. invenio_app_ils/literature/serializers/csv.py +1 -3
  133. invenio_app_ils/literature/serializers/json.py +1 -3
  134. invenio_app_ils/locations/api.py +2 -4
  135. invenio_app_ils/locations/indexer.py +3 -9
  136. invenio_app_ils/locations/loaders/__init__.py +1 -3
  137. invenio_app_ils/locations/loaders/jsonschemas/location.py +4 -11
  138. invenio_app_ils/locations/mappings/{v6 → os-v1}/__init__.py +1 -1
  139. invenio_app_ils/locations/mappings/os-v1/locations/location-v1.0.0.json +90 -0
  140. invenio_app_ils/locations/mappings/os-v2/__init__.py +8 -0
  141. invenio_app_ils/locations/mappings/os-v2/locations/location-v1.0.0.json +90 -0
  142. invenio_app_ils/notifications/messages.py +4 -3
  143. invenio_app_ils/notifications/tasks.py +1 -3
  144. invenio_app_ils/notifications/views.py +2 -2
  145. invenio_app_ils/patrons/anonymization.py +53 -32
  146. invenio_app_ils/patrons/api.py +3 -5
  147. invenio_app_ils/patrons/cli.py +1 -2
  148. invenio_app_ils/patrons/indexer.py +4 -13
  149. invenio_app_ils/patrons/mappings/os-v1/__init__.py +8 -0
  150. invenio_app_ils/patrons/mappings/os-v1/patrons/patron-v1.0.0.json +42 -0
  151. invenio_app_ils/patrons/mappings/os-v2/__init__.py +8 -0
  152. invenio_app_ils/patrons/mappings/os-v2/patrons/patron-v1.0.0.json +42 -0
  153. invenio_app_ils/patrons/views.py +4 -14
  154. invenio_app_ils/permissions.py +93 -35
  155. invenio_app_ils/providers/api.py +2 -6
  156. invenio_app_ils/providers/config.py +11 -19
  157. invenio_app_ils/providers/indexer.py +2 -6
  158. invenio_app_ils/providers/mappings/{v6 → os-v1}/__init__.py +1 -1
  159. invenio_app_ils/providers/mappings/os-v1/providers/provider-v1.0.0.json +57 -0
  160. invenio_app_ils/providers/mappings/os-v2/__init__.py +8 -0
  161. invenio_app_ils/providers/mappings/os-v2/providers/provider-v1.0.0.json +57 -0
  162. invenio_app_ils/providers/mappings/v7/__init__.py +1 -1
  163. invenio_app_ils/providers/proxies.py +1 -3
  164. invenio_app_ils/records/api.py +3 -9
  165. invenio_app_ils/records/loaders/schemas/changed_by.py +1 -3
  166. invenio_app_ils/records/loaders/schemas/identifiers.py +23 -0
  167. invenio_app_ils/records/metadata_extensions.py +1 -4
  168. invenio_app_ils/records/permissions.py +8 -2
  169. invenio_app_ils/records/serializers/__init__.py +1 -4
  170. invenio_app_ils/records/views.py +4 -7
  171. invenio_app_ils/records_relations/api.py +11 -34
  172. invenio_app_ils/records_relations/indexer.py +1 -3
  173. invenio_app_ils/records_relations/retriever.py +14 -9
  174. invenio_app_ils/records_relations/views.py +16 -50
  175. invenio_app_ils/relations/api.py +17 -16
  176. invenio_app_ils/search_permissions.py +24 -24
  177. invenio_app_ils/series/api.py +10 -12
  178. invenio_app_ils/series/loaders/jsonschemas/series.py +3 -2
  179. invenio_app_ils/{items/mappings/v6 → series/mappings/os-v1}/__init__.py +1 -1
  180. invenio_app_ils/series/mappings/os-v1/series/series-v1.0.0.json +324 -0
  181. invenio_app_ils/series/mappings/os-v1/series/series-v2.0.0.json +396 -0
  182. {tests/api/acquisition → invenio_app_ils/series/mappings/os-v2}/__init__.py +1 -1
  183. invenio_app_ils/series/mappings/os-v2/series/series-v1.0.0.json +324 -0
  184. invenio_app_ils/series/mappings/os-v2/series/series-v2.0.0.json +396 -0
  185. invenio_app_ils/series/mappings/v7/series/series-v1.0.0.json +35 -3
  186. invenio_app_ils/series/mappings/v7/series/series-v2.0.0.json +396 -0
  187. invenio_app_ils/series/schemas/series/series-v2.0.0.json +354 -0
  188. invenio_app_ils/stats/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.json +60 -0
  189. invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/__init__.py +9 -0
  190. invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.json +60 -0
  191. invenio_app_ils/stats/event_builders.py +73 -0
  192. invenio_app_ils/stats/file_download/os-v1/file-download-v1.json +72 -0
  193. invenio_app_ils/stats/file_download/os-v2/__init__.py +9 -0
  194. invenio_app_ils/stats/file_download/os-v2/file-download-v1.json +72 -0
  195. invenio_app_ils/stats/processors.py +30 -0
  196. invenio_app_ils/stats/templates/aggregations/__init__.py +8 -0
  197. invenio_app_ils/stats/templates/aggregations/ils_record_changes/__init__.py +8 -0
  198. invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/__init__.py +8 -0
  199. invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/aggr-ils-record-changes-v1.json +41 -0
  200. {tests → invenio_app_ils/stats/templates/events}/__init__.py +2 -2
  201. invenio_app_ils/stats/templates/events/ils_record_changes/__init__.py +8 -0
  202. invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/__init__.py +8 -0
  203. invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/ils-record-changes-v1.json +41 -0
  204. invenio_app_ils/templates/logged_out.html +12 -0
  205. invenio_app_ils/views.py +18 -4
  206. invenio_app_ils/vocabularies/api.py +1 -1
  207. invenio_app_ils/vocabularies/cli.py +6 -18
  208. invenio_app_ils/vocabularies/data/acq_order_line_payment_modes.json +5 -0
  209. invenio_app_ils/vocabularies/data/identifier_schemes.json +5 -0
  210. invenio_app_ils/vocabularies/indexer.py +1 -4
  211. invenio_app_ils/vocabularies/jsonresolvers/licenses.py +2 -11
  212. invenio_app_ils/vocabularies/mappings/os-v1/__init__.py +8 -0
  213. invenio_app_ils/vocabularies/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +23 -0
  214. invenio_app_ils/vocabularies/mappings/os-v2/__init__.py +8 -0
  215. invenio_app_ils/vocabularies/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +23 -0
  216. invenio_app_ils/vocabularies/sources/base.py +1 -3
  217. invenio_app_ils/webpack.py +27 -0
  218. invenio_app_ils-6.1.0.dist-info/METADATA +627 -0
  219. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/RECORD +227 -249
  220. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/WHEEL +1 -1
  221. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/entry_points.txt +9 -5
  222. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/top_level.txt +0 -1
  223. invenio_app_ils/acquisition/mappings/v6/acq_orders/order-v1.0.0.json +0 -352
  224. invenio_app_ils/document_requests/mappings/v6/document_requests/document_request-v1.0.0.json +0 -199
  225. invenio_app_ils/documents/mappings/v6/documents/document-v1.0.0.json +0 -843
  226. invenio_app_ils/eitems/mappings/v6/eitems/eitem-v1.0.0.json +0 -131
  227. invenio_app_ils/ill/mappings/v6/ill_borrowing_requests/borrowing_request-v1.0.0.json +0 -242
  228. invenio_app_ils/internal_locations/mappings/v6/internal_locations/internal_location-v1.0.0.json +0 -110
  229. invenio_app_ils/items/mappings/v6/items/item-v1.0.0.json +0 -276
  230. invenio_app_ils/locations/mappings/v6/locations/location-v1.0.0.json +0 -92
  231. invenio_app_ils/notifications/admin.py +0 -57
  232. invenio_app_ils/patrons/mappings/v6/__init__.py +0 -8
  233. invenio_app_ils/patrons/mappings/v6/patrons/patron-v1.0.0.json +0 -44
  234. invenio_app_ils/providers/mappings/v6/providers/provider-v1.0.0.json +0 -59
  235. invenio_app_ils/series/mappings/v6/series/series-v1.0.0.json +0 -298
  236. invenio_app_ils/stats/aggregations/aggr_file_download/v6/aggr-file-download-v1.json +0 -59
  237. invenio_app_ils/stats/file_download/v6/file-download-v1.json +0 -74
  238. invenio_app_ils/version.py +0 -14
  239. invenio_app_ils/vocabularies/mappings/v6/__init__.py +0 -8
  240. invenio_app_ils/vocabularies/mappings/v6/vocabularies/vocabulary-v1.0.0.json +0 -25
  241. invenio_app_ils-1.0.0a54.dist-info/METADATA +0 -95
  242. tests/api/__init__.py +0 -8
  243. tests/api/acquisition/test_acq_orders_crud.py +0 -102
  244. tests/api/acquisition/test_acq_orders_permissions.py +0 -104
  245. tests/api/acquisition/test_acq_providers_permissions.py +0 -83
  246. tests/api/circulation/test_expired_loans.py +0 -88
  247. tests/api/circulation/test_loan_checkout.py +0 -216
  248. tests/api/circulation/test_loan_default_durations.py +0 -57
  249. tests/api/circulation/test_loan_document_resolver.py +0 -18
  250. tests/api/circulation/test_loan_extend.py +0 -132
  251. tests/api/circulation/test_loan_item_permissions.py +0 -139
  252. tests/api/circulation/test_loan_item_resolver.py +0 -26
  253. tests/api/circulation/test_loan_list_permissions.py +0 -104
  254. tests/api/circulation/test_loan_patron_resolver.py +0 -38
  255. tests/api/circulation/test_loan_request.py +0 -234
  256. tests/api/circulation/test_loan_update.py +0 -150
  257. tests/api/circulation/test_notifications.py +0 -229
  258. tests/api/conftest.py +0 -236
  259. tests/api/document_requests/__init__.py +0 -8
  260. tests/api/document_requests/test_document_requests.py +0 -131
  261. tests/api/document_requests/test_document_requests_permissions.py +0 -177
  262. tests/api/document_requests/test_notifications_filter.py +0 -36
  263. tests/api/ill/test_ill_brw_crud.py +0 -84
  264. tests/api/ill/test_ill_brw_reqs_patron_loan_create_action.py +0 -207
  265. tests/api/ill/test_ill_brw_reqs_patron_loan_extension_actions.py +0 -298
  266. tests/api/ill/test_ill_brw_reqs_permissions.py +0 -169
  267. tests/api/ill/test_ill_providers_permissions.py +0 -82
  268. tests/api/ils/__init__.py +0 -8
  269. tests/api/ils/documents/__init__.py +0 -8
  270. tests/api/ils/documents/test_document_crud.py +0 -57
  271. tests/api/ils/documents/test_document_permissions.py +0 -106
  272. tests/api/ils/documents/test_document_resolvers.py +0 -35
  273. tests/api/ils/eitems/__init__.py +0 -8
  274. tests/api/ils/eitems/test_eitems_crud.py +0 -41
  275. tests/api/ils/eitems/test_eitems_permissions.py +0 -84
  276. tests/api/ils/eitems/test_files.py +0 -172
  277. tests/api/ils/items/__init__.py +0 -8
  278. tests/api/ils/items/test_apis.py +0 -43
  279. tests/api/ils/items/test_items_crud.py +0 -60
  280. tests/api/ils/items/test_items_permissions.py +0 -107
  281. tests/api/ils/items/test_items_update.py +0 -47
  282. tests/api/ils/records_relations/__init__.py +0 -8
  283. tests/api/ils/records_relations/helpers.py +0 -115
  284. tests/api/ils/records_relations/test_records_relations_parentchild.py +0 -560
  285. tests/api/ils/records_relations/test_records_relations_sequence.py +0 -302
  286. tests/api/ils/records_relations/test_records_relations_siblings.py +0 -678
  287. tests/api/ils/series/__init__.py +0 -8
  288. tests/api/ils/series/test_series_permissions.py +0 -95
  289. tests/api/ils/test_anonymization.py +0 -189
  290. tests/api/ils/test_apis.py +0 -76
  291. tests/api/ils/test_closures.py +0 -324
  292. tests/api/ils/test_errors.py +0 -126
  293. tests/api/ils/test_facets.py +0 -84
  294. tests/api/ils/test_internal_locations.py +0 -96
  295. tests/api/ils/test_loaders.py +0 -55
  296. tests/api/ils/test_metadata_extensions.py +0 -205
  297. tests/api/ils/test_notifications.py +0 -183
  298. tests/api/ils/test_notifications_mails.py +0 -39
  299. tests/api/ils/test_notifications_permissions.py +0 -55
  300. tests/api/ils/test_patrons.py +0 -106
  301. tests/api/ils/test_record_delete.py +0 -46
  302. tests/api/ils/test_record_permissions.py +0 -135
  303. tests/api/ils/test_resolvers.py +0 -207
  304. tests/api/ils/test_stats.py +0 -160
  305. tests/api/ils/test_tasks.py +0 -211
  306. tests/api/ils/test_vocabularies.py +0 -35
  307. tests/conftest.py +0 -123
  308. tests/data/acq_orders.json +0 -89
  309. tests/data/acq_providers.json +0 -12
  310. tests/data/document_requests.json +0 -77
  311. tests/data/documents.json +0 -237
  312. tests/data/eitems.json +0 -66
  313. tests/data/ill_borrowing_requests.json +0 -77
  314. tests/data/ill_providers.json +0 -12
  315. tests/data/internal_locations.json +0 -22
  316. tests/data/items.json +0 -271
  317. tests/data/loans.json +0 -133
  318. tests/data/loans_most_loaned.json +0 -128
  319. tests/data/locations.json +0 -20
  320. tests/data/series.json +0 -33
  321. tests/helpers.py +0 -104
  322. tests/templates/notifications/title_body.html +0 -8
  323. tests/templates/notifications/title_body_html.html +0 -13
  324. tests/templates/notifications/title_body_html_ctx.html +0 -13
  325. tests/templates/notifications/title_only.html +0 -3
  326. tests/test_version.py +0 -17
  327. /tests/templates/notifications/blank.html → /invenio_app_ils/acquisition/mappings/os-v1/__init__.py +0 -0
  328. /invenio_app_ils/stats/aggregations/aggr_file_download/{v6 → os-v1}/__init__.py +0 -0
  329. /invenio_app_ils/stats/file_download/{v6 → os-v1}/__init__.py +0 -0
  330. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/AUTHORS.rst +0 -0
  331. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,183 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018-2021 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 notifications."""
9
-
10
- import pytest
11
- from flask import url_for
12
- from jinja2.exceptions import TemplateError, TemplateNotFound
13
-
14
- from invenio_app_ils.notifications.api import (
15
- log_error_notification,
16
- log_successful_notification,
17
- send_notification,
18
- )
19
- from invenio_app_ils.notifications.messages import NotificationMsg
20
- from invenio_app_ils.notifications.models import NotificationsLogs
21
- from invenio_app_ils.patrons.api import Patron
22
- from tests.helpers import user_login
23
-
24
-
25
- def test_message_full(app_with_notifs):
26
- """Test that the title, body and html are read correctly."""
27
- with app_with_notifs.app_context():
28
- # remove footer
29
- app_with_notifs.config["ILS_NOTIFICATIONS_TEMPLATES"] = {}
30
-
31
- full = NotificationMsg("notifications/title_body_html.html")
32
- assert full.title == "Test title."
33
- assert "Test body." == full.body_plain
34
- assert "Test html." == full.body_html
35
-
36
-
37
- def test_message_body_same_as_html(app_with_notifs):
38
- """Test that the title and body are read correctly."""
39
- with app_with_notifs.app_context():
40
- # remove footer
41
- app_with_notifs.config["ILS_NOTIFICATIONS_TEMPLATES"] = {}
42
-
43
- blank = NotificationMsg("notifications/title_body.html")
44
- assert blank.title == "Test title."
45
- assert "Test body." == blank.body_plain
46
- assert "Test body." == blank.body_html
47
-
48
-
49
- def test_invalid_message_templates(app_with_notifs):
50
- """Test invalid templates."""
51
- with app_with_notifs.app_context():
52
- with pytest.raises(TemplateError) as ex:
53
- NotificationMsg("notifications/blank.html")
54
- assert "No block with name 'title'" in str(ex.value)
55
-
56
- with pytest.raises(TemplateError) as ex:
57
- NotificationMsg("notifications/title_only.html")
58
- assert "No block with name 'body_plain'" in str(ex.value)
59
-
60
-
61
- def test_message_templates_escaping(app_with_notifs):
62
- """Test templates escaping."""
63
- title = (
64
- "Spèciâl chäráctèrs: "
65
- "`,~,!,@,#,$,%,^,&,*,(,),_,-,+,=,{,[,},},|,\\,:,;,',<,>,.,?,/,º,ª "
66
- "<script>alert('test');</script>"
67
- )
68
- ctx = dict(title=title)
69
- with app_with_notifs.app_context():
70
- # remove footer
71
- app_with_notifs.config["ILS_NOTIFICATIONS_TEMPLATES"] = {}
72
-
73
- full = NotificationMsg("notifications/title_body_html_ctx.html", ctx)
74
-
75
- assert full.title == 'Test "{0}" title.'.format(title)
76
-
77
- from jinja2 import escape
78
-
79
- escaped = escape(title)
80
- assert 'Test "{0}" body.'.format(escaped) == full.body_plain
81
- assert 'Test "{0}" html.'.format(escaped) == full.body_html
82
-
83
-
84
- def test_message_with_missing_template(app_with_notifs):
85
- """Test that a missing template raises an exception."""
86
- with app_with_notifs.app_context():
87
- with pytest.raises(TemplateNotFound):
88
- NotificationMsg("missing.html")
89
-
90
-
91
- def test_send_message_backend(app_with_notifs, users, testdata, mocker):
92
- """Test that notifications backend is called when sending."""
93
- send_mocked = mocker.patch(
94
- "invenio_app_ils.notifications.backends.mail.send"
95
- )
96
- send_mocked.__name__ = "send"
97
- send_mocked.__annotations__ = "send"
98
- backends = mocker.patch(
99
- "invenio_app_ils.notifications.api._get_notification_backends",
100
- return_value=[send_mocked]
101
- )
102
- with app_with_notifs.app_context():
103
- # remove footer
104
- app_with_notifs.config["ILS_NOTIFICATIONS_TEMPLATES"] = {}
105
-
106
- msg = NotificationMsg("notifications/title_body_html.html")
107
- patrons = [Patron(users["patron1"].id)]
108
- send_notification(patrons, msg)
109
-
110
- assert send_mocked.apply_async.called
111
-
112
-
113
- class FakeMessage(NotificationMsg):
114
- def __init__(self, *args, **kwargs):
115
- template = kwargs.pop("template", "notifications/title_body_html.html")
116
- super().__init__(template, **kwargs)
117
-
118
-
119
- def test_log_successful_error_mail_task(
120
- app_with_notifs, users, testdata, mocker
121
- ):
122
- """Test that a successfully sent email is logged."""
123
- # !attention the mocker has to patch function where it is used, not defined
124
- succ = mocker.patch(
125
- "invenio_app_ils.notifications.api.log_successful_notification"
126
- )
127
- err = mocker.patch(
128
- "invenio_app_ils.notifications.api.log_error_notification"
129
- )
130
-
131
- patron = Patron(users["patron1"].id)
132
-
133
- assert not succ.s.called
134
- assert not err.s.called
135
- send_notification([patron], FakeMessage())
136
- assert succ.s.called
137
- assert err.s.called
138
-
139
-
140
- def test_notifications_db_table_and_endpoint(users, client, json_headers,
141
- app_with_notifs):
142
- """Test logging of notifs in db table and read from endpoint."""
143
- request = {"id": "test-id", "task": "test-task"}
144
- data = {
145
- "id": "test-id",
146
- "recipients": ["patron1@test.com"],
147
- "is_manually_triggered": True,
148
- "message_id": "1",
149
- "patron_id": "1",
150
- }
151
- exc = "An error occurred."
152
- log_successful_notification(None, data)
153
-
154
- log_error_notification(request=request, exc=exc, traceback=None, data=data)
155
-
156
- assert NotificationsLogs.query.filter_by(id=1).one().send_log == "Success"
157
- assert (
158
- NotificationsLogs.query.filter_by(id=2).one().send_log
159
- == "Error: 'An error occurred.'"
160
- )
161
-
162
- ITEM_ENDPOINT = "invenio_app_ils_notifications.get_notification"
163
- LIST_ENDPOINT = "invenio_app_ils_notifications.get_notifications"
164
-
165
- user_login(client, "librarian", users)
166
- url = url_for(LIST_ENDPOINT)
167
- res = client.get(url, headers=json_headers)
168
- assert (
169
- res.get_json()["hits"][0]["send_log"] == "Error: 'An error occurred.'"
170
- )
171
- assert res.get_json()["hits"][1]["send_log"] == "Success"
172
-
173
- url = url_for(ITEM_ENDPOINT, id=1)
174
- res = client.get(url, headers=json_headers)
175
- assert res.get_json()["send_log"] == "Success"
176
- assert res.get_json()["id"] == 1
177
-
178
- url = url_for(ITEM_ENDPOINT, id=2)
179
- res = client.get(url, headers=json_headers)
180
-
181
- assert res.get_json()["send_log"] ==\
182
- "Error: 'An error occurred.'"
183
- assert res.get_json()["id"] == 2
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2021 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 notifications backend emails."""
9
-
10
- from invenio_app_ils.notifications.api import send_notification
11
- from invenio_app_ils.notifications.messages import NotificationMsg
12
- from invenio_app_ils.patrons.api import Patron
13
-
14
-
15
- class FakeMessage(NotificationMsg):
16
- def __init__(self, *args, **kwargs):
17
- template = kwargs.pop("template", "notifications/title_body_html.html")
18
- super().__init__(template, **kwargs)
19
-
20
-
21
- def test_send_only_to_test_recipients(app_with_notifs, users, testdata,
22
- mocker):
23
- """Tests that send only to test recipients works."""
24
- app_with_notifs.config["ILS_MAIL_ENABLE_TEST_RECIPIENTS"] = True
25
- succ = mocker.patch(
26
- "invenio_app_ils.notifications.api.log_successful_notification")
27
-
28
- msg = FakeMessage()
29
- patron = Patron(users["patron1"].id)
30
-
31
- fake_recipients = app_with_notifs.config["ILS_MAIL_NOTIFY_TEST_RECIPIENTS"]
32
- with app_with_notifs.extensions["mail"].record_messages() as outbox:
33
- assert len(outbox) == 0
34
- send_notification([patron], msg)
35
- assert succ.s.called
36
- assert len(outbox) == 1
37
- assert outbox[0].recipients == fake_recipients
38
-
39
- app_with_notifs.config["ILS_MAIL_ENABLE_TEST_RECIPIENTS"] = False
@@ -1,55 +0,0 @@
1
- # Copyright (C) 2021 CERN.
2
- #
3
- # invenio-app-ils is free software; you can redistribute it and/or modify it
4
- # under the terms of the MIT License; see LICENSE file for more details.
5
-
6
- """Test notifications permissions."""
7
-
8
- from flask import url_for
9
-
10
- from tests.helpers import user_login
11
-
12
- _HTTP_OK = [200, 201, 204]
13
- _HTTP_UNAUTHORIZED = [401]
14
- _HTTP_FORBIDDEN = [403]
15
- _HTTP_NOT_FOUND = [404]
16
- MAIL_ID = 1
17
- ITEM_ENDPOINT = "invenio_app_ils_notifications.get_notification"
18
- LIST_ENDPOINT = "invenio_app_ils_notifications.get_notifications"
19
-
20
-
21
- def test_notifications_read_permissions(client, json_headers, users):
22
- """Test notifications endpoints read permissions."""
23
- list_tests = [
24
- ("admin", _HTTP_OK),
25
- ("librarian", _HTTP_OK),
26
- ("patron1", _HTTP_FORBIDDEN),
27
- ("anonymous", _HTTP_UNAUTHORIZED),
28
- ]
29
-
30
- item_tests = [
31
- ("admin", _HTTP_NOT_FOUND),
32
- ("librarian", _HTTP_NOT_FOUND),
33
- ("patron1", _HTTP_FORBIDDEN),
34
- ("anonymous", _HTTP_UNAUTHORIZED),
35
- ]
36
-
37
- def _test_list(expected_status):
38
- """Test get list."""
39
- url = url_for(LIST_ENDPOINT)
40
- res = client.get(url, headers=json_headers)
41
- assert res.status_code in expected_status
42
-
43
- def _test_read(expected_status, id):
44
- """Test record read."""
45
- url = url_for(ITEM_ENDPOINT, id=id)
46
- res = client.get(url, headers=json_headers)
47
- assert res.status_code in expected_status
48
-
49
- for username, expected_status in list_tests:
50
- user_login(client, username, users)
51
- _test_list(expected_status)
52
-
53
- for username, expected_status in item_tests:
54
- user_login(client, username, users)
55
- _test_read(expected_status, MAIL_ID)
@@ -1,106 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2019 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 patrons endpoint."""
9
-
10
- import json
11
-
12
- from flask import url_for
13
-
14
- from tests.helpers import user_login
15
-
16
- _LIST_ENDPOINT = "invenio_records_rest.patid_list"
17
-
18
-
19
- def _patron_loans_request(client, json_headers, document_pid):
20
- """Perform a patron loans request."""
21
- response = client.get(
22
- url_for(
23
- "invenio_app_ils_patrons.get_user_information",
24
- document_pid=document_pid,
25
- ),
26
- headers=json_headers,
27
- )
28
- return json.loads(response.data.decode("utf-8"))
29
-
30
-
31
- def _assert_patron_loans_information(
32
- client, json_headers, document_pid, expect
33
- ):
34
- """Assert patron loan information."""
35
- resp = _patron_loans_request(client, json_headers, document_pid)
36
- assert resp == expect
37
-
38
-
39
- def _assert_error_when_not_authenticated(client, json_headers, document_pid):
40
- """Assert user is not logged in."""
41
- resp = _patron_loans_request(client, json_headers, document_pid)
42
- assert resp["status"] == 401
43
-
44
-
45
- def test_patrons_permissions(client, testdata, json_headers, users):
46
- """Test patron endpoints permissions."""
47
- tests = [
48
- ("admin", [200]),
49
- ("librarian", [200]),
50
- ("patron1", [403]),
51
- ("anonymous", [401]),
52
- ]
53
-
54
- def _test_list(expected_status):
55
- """Test get list."""
56
- url = url_for(_LIST_ENDPOINT)
57
- res = client.get(url, headers=json_headers)
58
- assert res.status_code in expected_status
59
-
60
- for username, expected_status in tests:
61
- user_login(client, username, users)
62
- _test_list(expected_status)
63
-
64
-
65
- def test_patron_loans_information(
66
- client, json_headers, testdata_most_loaned, users
67
- ):
68
- """Test patron loans information API endpoint."""
69
- _assert_error_when_not_authenticated(client, json_headers, "docid-1")
70
- user_login(client, "librarian", users)
71
-
72
- _assert_patron_loans_information(
73
- client,
74
- json_headers,
75
- "docid-1",
76
- expect={
77
- "has_active_loan": False,
78
- "is_requested": False,
79
- "last_loan": None,
80
- },
81
- )
82
-
83
- user_login(client, "patron1", users)
84
-
85
- _assert_patron_loans_information(
86
- client,
87
- json_headers,
88
- "docid-1",
89
- expect={
90
- "has_active_loan": False,
91
- "is_requested": True,
92
- "last_loan": "2019-04-02",
93
- },
94
- )
95
-
96
- user_login(client, "patron2", users)
97
- _assert_patron_loans_information(
98
- client,
99
- json_headers,
100
- "docid-3",
101
- expect={
102
- "has_active_loan": False,
103
- "is_requested": True,
104
- "last_loan": None,
105
- },
106
- )
@@ -1,46 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018-19 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 record delete."""
9
-
10
- from flask import url_for
11
-
12
- from tests.helpers import user_login
13
-
14
-
15
- def test_delete_location(client, users, json_headers, testdata):
16
- """Test DELETE existing location."""
17
- user_login(client, "admin", users)
18
-
19
- location_pid = "locid-1"
20
- url = url_for("invenio_records_rest.locid_item", pid_value=location_pid)
21
- res = client.delete(url, headers=json_headers)
22
- assert res.status_code == 400
23
-
24
- location_pid = "locid-3"
25
- url = url_for("invenio_records_rest.locid_item", pid_value=location_pid)
26
- res = client.delete(url, headers=json_headers)
27
- assert res.status_code == 204
28
-
29
-
30
- def test_delete_internal_location(client, users, json_headers, testdata):
31
- """Test DELETE existing internal_location."""
32
- user_login(client, "admin", users)
33
-
34
- internal_location_pid = "ilocid-1"
35
- url = url_for(
36
- "invenio_records_rest.ilocid_item", pid_value=internal_location_pid
37
- )
38
- res = client.delete(url, headers=json_headers)
39
- assert res.status_code == 400
40
-
41
- internal_location_pid = "ilocid-3"
42
- url = url_for(
43
- "invenio_records_rest.ilocid_item", pid_value=internal_location_pid
44
- )
45
- res = client.delete(url, headers=json_headers)
46
- assert res.status_code == 204
@@ -1,135 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018-2019 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 record permissions."""
9
-
10
- import uuid
11
-
12
- import pytest
13
- from flask_principal import RoleNeed, identity_loaded
14
- from invenio_access.models import ActionRoles
15
- from invenio_accounts.models import Role
16
- from invenio_records.api import Record
17
- from invenio_search.api import RecordsSearch
18
-
19
- from invenio_app_ils.errors import UnauthorizedSearchError
20
- from invenio_app_ils.records.permissions import (
21
- RecordPermission,
22
- create_records_action,
23
- )
24
- from invenio_app_ils.search_permissions import _filter_by_patron
25
- from tests.helpers import user_login
26
-
27
-
28
- @pytest.mark.parametrize(
29
- "patron_pid,qs,should_raise",
30
- [
31
- ("1", None, False),
32
- ("1", "", False),
33
- ("1", "pid:1234", False),
34
- ("1", "patron_pid:2", True),
35
- ("1", "patron_pid: 2", True),
36
- ("1", "patron_pid: '2'", False),
37
- ("1", "pid:1234 AND patron_pid:2", True),
38
- ],
39
- )
40
- def test_filter_by_patron(app, patron_pid, qs, should_raise):
41
- """Test the function filter_by_patron."""
42
- search = RecordsSearch()
43
- if should_raise:
44
- with pytest.raises(UnauthorizedSearchError):
45
- _filter_by_patron(patron_pid, search, qs)
46
- else:
47
- _search, _qs = _filter_by_patron(patron_pid, search, qs)
48
- term = _search.to_dict()["query"]["bool"]["filter"][0]["term"]
49
- assert term == {"patron_pid": patron_pid}
50
-
51
-
52
- def test_record_generic_access(client, db, users, with_access):
53
- """Test access control for records."""
54
-
55
- tests = [
56
- ({"foo": "bar"}, "read", True),
57
- ({"foo": "bar"}, "update", False),
58
- ({"_access": {"read": [1]}}, "read", True),
59
- ({"_access": {"read": [2]}}, "read", False),
60
- ({"_access": {"read": ["records-readers"]}}, "read", True),
61
- # permission for specific user to create
62
- ({"_access": {"update": [1]}}, "update", True),
63
- # checks if the access works for different actions
64
- ({"_access": {"update": [1]}}, "create", False),
65
- ({"_access": {"delete": [1]}}, "update", False),
66
- # delete access for user and librarian
67
- ({"_access": {"delete": [1, "librarian"]}}, "delete", True),
68
- ]
69
-
70
- @identity_loaded.connect
71
- def add_roles_to_identity(sender, identity):
72
- """Provide additional role to the user."""
73
- roles = [RoleNeed("records-readers")]
74
- identity.provides |= set(roles)
75
-
76
- def login_and_test(username):
77
- user = user_login(client, username, users)
78
- # Create record
79
- id = uuid.uuid4()
80
- record = Record.create(access, id_=id)
81
- factory = RecordPermission(record, action)
82
- if user.has_role("admin"):
83
- # super user can do EVERYTHING
84
- assert factory.can()
85
- elif user.has_role("librarian") and action != "delete":
86
- # librarian should be able to update, create, and read everything
87
- assert factory.can()
88
- else:
89
- assert factory.can() if is_allowed else not factory.can()
90
-
91
- for access, action, is_allowed in tests:
92
- # Test standard user
93
- login_and_test("patron1")
94
- # Test librarian access
95
- login_and_test("librarian")
96
- # Test superuser access
97
- login_and_test("admin")
98
-
99
-
100
- @pytest.fixture()
101
- def with_role_creator(db):
102
- """"Create a new role and assign action."""
103
- role = Role(name="records-creators")
104
- db.session.add(role)
105
- db.session.commit()
106
- # assign role to the action "create-records"
107
- ar = ActionRoles.allow(create_records_action, role_id=role.id)
108
- db.session.add(ar)
109
- db.session.commit()
110
-
111
-
112
- def test_record_patron_create(client, db, users, with_role_creator):
113
- """Test patron create."""
114
-
115
- tests = [
116
- ({"foo": "bar"}, "create", True),
117
- ({"foo": "bar"}, "update", False),
118
- ({"foo": "bar"}, "delete", False),
119
- ]
120
-
121
- @identity_loaded.connect
122
- def add_roles_to_identity(sender, identity):
123
- """Provide additional role to the user."""
124
- roles = [RoleNeed("records-creators")]
125
- identity.provides |= set(roles)
126
-
127
- for access, action, is_allowed in tests:
128
- # create role to be able to create records
129
- user_login(client, "patron1", users)
130
-
131
- id = uuid.uuid4()
132
- record = Record.create(access, id_=id)
133
- factory = RecordPermission(record, action)
134
-
135
- assert factory.can() if is_allowed else not factory.can()