invenio-vocabularies 1.2.0__py2.py3-none-any.whl → 6.3.1__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.

Potentially problematic release.


This version of invenio-vocabularies might be problematic. Click here for more details.

Files changed (239) hide show
  1. invenio_vocabularies/__init__.py +2 -2
  2. invenio_vocabularies/administration/__init__.py +10 -0
  3. invenio_vocabularies/administration/views/__init__.py +10 -0
  4. invenio_vocabularies/administration/views/vocabularies.py +45 -0
  5. invenio_vocabularies/alembic/4a9a4fd235f8_create_vocabulary_schemes.py +4 -4
  6. invenio_vocabularies/alembic/4f365fced43f_create_vocabularies_tables.py +2 -2
  7. invenio_vocabularies/alembic/55a700f897b6_add_names_and_afiliations_pid_column.py +96 -0
  8. invenio_vocabularies/alembic/676dd587542d_create_funders_vocabulary_table.py +1 -1
  9. invenio_vocabularies/alembic/e1146238edd3_create_awards_table.py +1 -1
  10. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/.eslintrc.yml +11 -0
  11. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/.prettierrc +1 -0
  12. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/index.js +7 -0
  13. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/package.json +25 -0
  14. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/AwardResults.js +95 -0
  15. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/CustomAwardForm.js +139 -0
  16. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FunderDropdown.js +87 -0
  17. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingField.js +223 -0
  18. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingField.test.js +1 -0
  19. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingFieldItem.js +152 -0
  20. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingModal.js +270 -0
  21. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/NoAwardResults.js +37 -0
  22. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/index.js +8 -0
  23. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/index.js +7 -0
  24. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/index.js +7 -0
  25. invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/index.js +7 -0
  26. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/i18next-scanner.config.js +63 -0
  27. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/i18next.js +36 -0
  28. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/messages/index.js +1 -0
  29. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/package.json +53 -0
  30. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/scripts/compileCatalog.js +39 -0
  31. invenio_vocabularies/assets/semantic-ui/translations/invenio_vocabularies/scripts/initCatalog.js +19 -0
  32. invenio_vocabularies/cli.py +31 -44
  33. invenio_vocabularies/config.py +74 -7
  34. invenio_vocabularies/contrib/affiliations/affiliations.py +22 -6
  35. invenio_vocabularies/contrib/affiliations/api.py +1 -2
  36. invenio_vocabularies/contrib/affiliations/config.py +10 -5
  37. invenio_vocabularies/contrib/affiliations/datastreams.py +186 -0
  38. invenio_vocabularies/contrib/affiliations/facets.py +36 -0
  39. invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json +38 -7
  40. invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v1.0.0.json +22 -1
  41. invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json +171 -0
  42. invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v1.0.0.json +22 -1
  43. invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json +171 -0
  44. invenio_vocabularies/contrib/affiliations/mappings/v7/affiliations/affiliation-v1.0.0.json +22 -1
  45. invenio_vocabularies/contrib/affiliations/schema.py +23 -5
  46. invenio_vocabularies/contrib/affiliations/services.py +1 -2
  47. invenio_vocabularies/contrib/awards/awards.py +18 -6
  48. invenio_vocabularies/contrib/awards/config.py +1 -3
  49. invenio_vocabularies/contrib/awards/datastreams.py +246 -3
  50. invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json +41 -0
  51. invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json +53 -1
  52. invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json +53 -1
  53. invenio_vocabularies/contrib/awards/mappings/v7/awards/award-v1.0.0.json +53 -1
  54. invenio_vocabularies/contrib/awards/schema.py +27 -35
  55. invenio_vocabularies/contrib/awards/serializer.py +9 -1
  56. invenio_vocabularies/contrib/awards/services.py +1 -2
  57. invenio_vocabularies/contrib/common/__init__.py +9 -0
  58. invenio_vocabularies/contrib/common/openaire/__init__.py +9 -0
  59. invenio_vocabularies/contrib/common/openaire/datastreams.py +84 -0
  60. invenio_vocabularies/contrib/common/ror/__init__.py +9 -0
  61. invenio_vocabularies/contrib/common/ror/datastreams.py +220 -0
  62. invenio_vocabularies/contrib/funders/config.py +12 -5
  63. invenio_vocabularies/contrib/funders/datastreams.py +40 -62
  64. invenio_vocabularies/contrib/funders/facets.py +13 -5
  65. invenio_vocabularies/contrib/funders/funders.py +4 -2
  66. invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json +36 -1
  67. invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v1.0.0.json +22 -1
  68. invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json +156 -0
  69. invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v1.0.0.json +22 -1
  70. invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json +156 -0
  71. invenio_vocabularies/contrib/funders/mappings/v7/funders/funder-v1.0.0.json +22 -1
  72. invenio_vocabularies/contrib/funders/schema.py +8 -0
  73. invenio_vocabularies/contrib/funders/serializer.py +2 -1
  74. invenio_vocabularies/contrib/names/config.py +5 -3
  75. invenio_vocabularies/contrib/names/datastreams.py +177 -38
  76. invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json +2 -6
  77. invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v1.0.0.json +3 -0
  78. invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json +150 -0
  79. invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v1.0.0.json +3 -0
  80. invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json +150 -0
  81. invenio_vocabularies/contrib/names/mappings/v7/names/name-v1.0.0.json +3 -0
  82. invenio_vocabularies/contrib/names/names.py +29 -13
  83. invenio_vocabularies/contrib/names/permissions.py +20 -0
  84. invenio_vocabularies/contrib/names/s3client.py +44 -0
  85. invenio_vocabularies/contrib/names/schema.py +31 -4
  86. invenio_vocabularies/contrib/subjects/config.py +9 -3
  87. invenio_vocabularies/contrib/subjects/datastreams.py +61 -0
  88. invenio_vocabularies/contrib/subjects/euroscivoc/__init__.py +9 -0
  89. invenio_vocabularies/contrib/subjects/euroscivoc/datastreams.py +171 -0
  90. invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json +31 -0
  91. invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json +35 -0
  92. invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json +35 -0
  93. invenio_vocabularies/contrib/subjects/mappings/v7/subjects/subject-v1.0.0.json +35 -0
  94. invenio_vocabularies/contrib/subjects/mesh/__init__.py +9 -0
  95. invenio_vocabularies/contrib/subjects/mesh/datastreams.py +43 -0
  96. invenio_vocabularies/contrib/subjects/schema.py +47 -5
  97. invenio_vocabularies/contrib/subjects/subjects.py +10 -0
  98. invenio_vocabularies/datastreams/datastreams.py +61 -13
  99. invenio_vocabularies/datastreams/factories.py +1 -2
  100. invenio_vocabularies/datastreams/readers.py +138 -29
  101. invenio_vocabularies/datastreams/tasks.py +37 -0
  102. invenio_vocabularies/datastreams/transformers.py +17 -27
  103. invenio_vocabularies/datastreams/writers.py +116 -14
  104. invenio_vocabularies/datastreams/xml.py +34 -0
  105. invenio_vocabularies/ext.py +59 -5
  106. invenio_vocabularies/factories.py +137 -0
  107. invenio_vocabularies/jobs.py +133 -0
  108. invenio_vocabularies/proxies.py +2 -2
  109. invenio_vocabularies/records/jsonschemas/vocabularies/definitions-v1.0.0.json +7 -0
  110. invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json +1 -4
  111. invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +3 -3
  112. invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +3 -3
  113. invenio_vocabularies/records/mappings/v7/vocabularies/vocabulary-v1.0.0.json +3 -3
  114. invenio_vocabularies/records/models.py +8 -10
  115. invenio_vocabularies/records/pidprovider.py +1 -2
  116. invenio_vocabularies/records/systemfields/relations.py +2 -2
  117. invenio_vocabularies/resources/__init__.py +9 -1
  118. invenio_vocabularies/resources/config.py +105 -0
  119. invenio_vocabularies/resources/resource.py +31 -41
  120. invenio_vocabularies/resources/schema.py +2 -1
  121. invenio_vocabularies/services/__init__.py +5 -2
  122. invenio_vocabularies/services/config.py +179 -0
  123. invenio_vocabularies/services/custom_fields/__init__.py +6 -2
  124. invenio_vocabularies/services/custom_fields/subject.py +82 -0
  125. invenio_vocabularies/services/custom_fields/vocabulary.py +19 -9
  126. invenio_vocabularies/services/facets.py +67 -37
  127. invenio_vocabularies/services/permissions.py +3 -1
  128. invenio_vocabularies/services/results.py +110 -0
  129. invenio_vocabularies/services/schema.py +39 -2
  130. invenio_vocabularies/services/service.py +46 -94
  131. invenio_vocabularies/services/tasks.py +1 -1
  132. invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/subjects.html +23 -0
  133. invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabularies-list.html +12 -0
  134. invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabulary-details.html +71 -0
  135. invenio_vocabularies/translations/af/LC_MESSAGES/messages.mo +0 -0
  136. invenio_vocabularies/translations/af/LC_MESSAGES/messages.po +1 -1
  137. invenio_vocabularies/translations/ar/LC_MESSAGES/messages.mo +0 -0
  138. invenio_vocabularies/translations/ar/LC_MESSAGES/messages.po +9 -8
  139. invenio_vocabularies/translations/bg/LC_MESSAGES/messages.mo +0 -0
  140. invenio_vocabularies/translations/bg/LC_MESSAGES/messages.po +1 -1
  141. invenio_vocabularies/translations/ca/LC_MESSAGES/messages.mo +0 -0
  142. invenio_vocabularies/translations/ca/LC_MESSAGES/messages.po +1 -1
  143. invenio_vocabularies/translations/cs/LC_MESSAGES/messages.mo +0 -0
  144. invenio_vocabularies/translations/cs/LC_MESSAGES/messages.po +1 -1
  145. invenio_vocabularies/translations/da/LC_MESSAGES/messages.mo +0 -0
  146. invenio_vocabularies/translations/da/LC_MESSAGES/messages.po +1 -1
  147. invenio_vocabularies/translations/de/LC_MESSAGES/messages.mo +0 -0
  148. invenio_vocabularies/translations/de/LC_MESSAGES/messages.po +1 -1
  149. invenio_vocabularies/translations/de_AT/LC_MESSAGES/messages.mo +0 -0
  150. invenio_vocabularies/translations/de_AT/LC_MESSAGES/messages.po +139 -0
  151. invenio_vocabularies/translations/de_DE/LC_MESSAGES/messages.mo +0 -0
  152. invenio_vocabularies/translations/de_DE/LC_MESSAGES/messages.po +139 -0
  153. invenio_vocabularies/translations/el/LC_MESSAGES/messages.mo +0 -0
  154. invenio_vocabularies/translations/el/LC_MESSAGES/messages.po +1 -1
  155. invenio_vocabularies/translations/en/LC_MESSAGES/messages.mo +0 -0
  156. invenio_vocabularies/translations/en_AT/LC_MESSAGES/messages.mo +0 -0
  157. invenio_vocabularies/translations/en_AT/LC_MESSAGES/messages.po +139 -0
  158. invenio_vocabularies/translations/en_HU/LC_MESSAGES/messages.mo +0 -0
  159. invenio_vocabularies/translations/en_HU/LC_MESSAGES/messages.po +139 -0
  160. invenio_vocabularies/translations/es/LC_MESSAGES/messages.mo +0 -0
  161. invenio_vocabularies/translations/es/LC_MESSAGES/messages.po +1 -1
  162. invenio_vocabularies/translations/es_CU/LC_MESSAGES/messages.mo +0 -0
  163. invenio_vocabularies/translations/es_CU/LC_MESSAGES/messages.po +139 -0
  164. invenio_vocabularies/translations/es_MX/LC_MESSAGES/messages.mo +0 -0
  165. invenio_vocabularies/translations/es_MX/LC_MESSAGES/messages.po +139 -0
  166. invenio_vocabularies/translations/et/LC_MESSAGES/messages.mo +0 -0
  167. invenio_vocabularies/translations/et/LC_MESSAGES/messages.po +1 -1
  168. invenio_vocabularies/translations/et_EE/LC_MESSAGES/messages.mo +0 -0
  169. invenio_vocabularies/translations/et_EE/LC_MESSAGES/messages.po +1 -1
  170. invenio_vocabularies/translations/fa/LC_MESSAGES/messages.mo +0 -0
  171. invenio_vocabularies/translations/fa/LC_MESSAGES/messages.po +1 -1
  172. invenio_vocabularies/translations/fa_IR/LC_MESSAGES/messages.mo +0 -0
  173. invenio_vocabularies/translations/fa_IR/LC_MESSAGES/messages.po +139 -0
  174. invenio_vocabularies/translations/fr/LC_MESSAGES/messages.mo +0 -0
  175. invenio_vocabularies/translations/fr/LC_MESSAGES/messages.po +1 -1
  176. invenio_vocabularies/translations/fr_CI/LC_MESSAGES/messages.mo +0 -0
  177. invenio_vocabularies/translations/fr_CI/LC_MESSAGES/messages.po +139 -0
  178. invenio_vocabularies/translations/fr_FR/LC_MESSAGES/messages.mo +0 -0
  179. invenio_vocabularies/translations/fr_FR/LC_MESSAGES/messages.po +139 -0
  180. invenio_vocabularies/translations/gl/LC_MESSAGES/messages.mo +0 -0
  181. invenio_vocabularies/translations/gl/LC_MESSAGES/messages.po +1 -1
  182. invenio_vocabularies/translations/hi_IN/LC_MESSAGES/messages.mo +0 -0
  183. invenio_vocabularies/translations/hi_IN/LC_MESSAGES/messages.po +139 -0
  184. invenio_vocabularies/translations/hr/LC_MESSAGES/messages.mo +0 -0
  185. invenio_vocabularies/translations/hr/LC_MESSAGES/messages.po +1 -1
  186. invenio_vocabularies/translations/hu/LC_MESSAGES/messages.mo +0 -0
  187. invenio_vocabularies/translations/hu/LC_MESSAGES/messages.po +4 -4
  188. invenio_vocabularies/translations/hu_HU/LC_MESSAGES/messages.mo +0 -0
  189. invenio_vocabularies/translations/hu_HU/LC_MESSAGES/messages.po +139 -0
  190. invenio_vocabularies/translations/it/LC_MESSAGES/messages.mo +0 -0
  191. invenio_vocabularies/translations/it/LC_MESSAGES/messages.po +4 -3
  192. invenio_vocabularies/translations/ja/LC_MESSAGES/messages.mo +0 -0
  193. invenio_vocabularies/translations/ja/LC_MESSAGES/messages.po +1 -1
  194. invenio_vocabularies/translations/ka/LC_MESSAGES/messages.mo +0 -0
  195. invenio_vocabularies/translations/ka/LC_MESSAGES/messages.po +1 -1
  196. invenio_vocabularies/translations/lt/LC_MESSAGES/messages.mo +0 -0
  197. invenio_vocabularies/translations/lt/LC_MESSAGES/messages.po +1 -1
  198. invenio_vocabularies/translations/messages.pot +95 -48
  199. invenio_vocabularies/translations/ne/LC_MESSAGES/messages.mo +0 -0
  200. invenio_vocabularies/translations/ne/LC_MESSAGES/messages.po +139 -0
  201. invenio_vocabularies/translations/no/LC_MESSAGES/messages.mo +0 -0
  202. invenio_vocabularies/translations/no/LC_MESSAGES/messages.po +1 -1
  203. invenio_vocabularies/translations/pl/LC_MESSAGES/messages.mo +0 -0
  204. invenio_vocabularies/translations/pl/LC_MESSAGES/messages.po +1 -1
  205. invenio_vocabularies/translations/pt/LC_MESSAGES/messages.mo +0 -0
  206. invenio_vocabularies/translations/pt/LC_MESSAGES/messages.po +1 -1
  207. invenio_vocabularies/translations/ro/LC_MESSAGES/messages.mo +0 -0
  208. invenio_vocabularies/translations/ro/LC_MESSAGES/messages.po +1 -1
  209. invenio_vocabularies/translations/ru/LC_MESSAGES/messages.mo +0 -0
  210. invenio_vocabularies/translations/ru/LC_MESSAGES/messages.po +1 -1
  211. invenio_vocabularies/translations/rw/LC_MESSAGES/messages.mo +0 -0
  212. invenio_vocabularies/translations/rw/LC_MESSAGES/messages.po +1 -1
  213. invenio_vocabularies/translations/sk/LC_MESSAGES/messages.mo +0 -0
  214. invenio_vocabularies/translations/sk/LC_MESSAGES/messages.po +1 -1
  215. invenio_vocabularies/translations/sv/LC_MESSAGES/messages.mo +0 -0
  216. invenio_vocabularies/translations/sv/LC_MESSAGES/messages.po +4 -3
  217. invenio_vocabularies/translations/sv_SE/LC_MESSAGES/messages.mo +0 -0
  218. invenio_vocabularies/translations/sv_SE/LC_MESSAGES/messages.po +139 -0
  219. invenio_vocabularies/translations/tr/LC_MESSAGES/messages.mo +0 -0
  220. invenio_vocabularies/translations/tr/LC_MESSAGES/messages.po +1 -1
  221. invenio_vocabularies/translations/uk/LC_MESSAGES/messages.mo +0 -0
  222. invenio_vocabularies/translations/uk/LC_MESSAGES/messages.po +17 -13
  223. invenio_vocabularies/translations/uk_UA/LC_MESSAGES/messages.mo +0 -0
  224. invenio_vocabularies/translations/uk_UA/LC_MESSAGES/messages.po +139 -0
  225. invenio_vocabularies/translations/zh_CN/LC_MESSAGES/messages.mo +0 -0
  226. invenio_vocabularies/translations/zh_CN/LC_MESSAGES/messages.po +1 -1
  227. invenio_vocabularies/translations/zh_TW/LC_MESSAGES/messages.mo +0 -0
  228. invenio_vocabularies/translations/zh_TW/LC_MESSAGES/messages.po +1 -1
  229. invenio_vocabularies/views.py +12 -26
  230. invenio_vocabularies/webpack.py +51 -0
  231. invenio_vocabularies-6.3.1.dist-info/METADATA +346 -0
  232. invenio_vocabularies-6.3.1.dist-info/RECORD +306 -0
  233. {invenio_vocabularies-1.2.0.dist-info → invenio_vocabularies-6.3.1.dist-info}/WHEEL +1 -1
  234. {invenio_vocabularies-1.2.0.dist-info → invenio_vocabularies-6.3.1.dist-info}/entry_points.txt +20 -0
  235. invenio_vocabularies-1.2.0.dist-info/METADATA +0 -133
  236. invenio_vocabularies-1.2.0.dist-info/RECORD +0 -220
  237. {invenio_vocabularies-1.2.0.dist-info → invenio_vocabularies-6.3.1.dist-info}/AUTHORS.rst +0 -0
  238. {invenio_vocabularies-1.2.0.dist-info → invenio_vocabularies-6.3.1.dist-info}/LICENSE +0 -0
  239. {invenio_vocabularies-1.2.0.dist-info → invenio_vocabularies-6.3.1.dist-info}/top_level.txt +0 -0
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "title": {
83
83
  "type": "object",
84
- "dynamic": true,
84
+ "dynamic": "true",
85
85
  "properties": {
86
86
  "en": {
87
87
  "type": "search_as_you_type",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "description": {
93
93
  "type": "object",
94
- "dynamic": true
94
+ "dynamic": "true"
95
95
  },
96
96
  "icon": {
97
97
  "type": "keyword",
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "props": {
104
104
  "type": "object",
105
- "dynamic": true
105
+ "dynamic": "true"
106
106
  }
107
107
  }
108
108
  }
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "title": {
83
83
  "type": "object",
84
- "dynamic": true,
84
+ "dynamic": "true",
85
85
  "properties": {
86
86
  "en": {
87
87
  "type": "search_as_you_type",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "description": {
93
93
  "type": "object",
94
- "dynamic": true
94
+ "dynamic": "true"
95
95
  },
96
96
  "icon": {
97
97
  "type": "keyword",
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "props": {
104
104
  "type": "object",
105
- "dynamic": true
105
+ "dynamic": "true"
106
106
  }
107
107
  }
108
108
  }
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2020-2021 CERN.
3
+ # Copyright (C) 2020-2024 CERN.
4
4
  #
5
5
  # Invenio-Vocabularies is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the MIT License; see LICENSE file for more
@@ -17,8 +17,8 @@ class VocabularyType(db.Model):
17
17
 
18
18
  __tablename__ = "vocabularies_types"
19
19
 
20
- id = db.Column(db.String, primary_key=True)
21
- pid_type = db.Column(db.String, unique=True)
20
+ id = db.Column(db.String(255), primary_key=True)
21
+ pid_type = db.Column(db.String(255), unique=True)
22
22
 
23
23
  @classmethod
24
24
  def create(cls, **data):
@@ -67,11 +67,11 @@ class VocabularyScheme(db.Model):
67
67
 
68
68
  __tablename__ = "vocabularies_schemes"
69
69
 
70
- id = db.Column(db.String, primary_key=True)
70
+ id = db.Column(db.String(255), primary_key=True)
71
71
  # This is e.g. `subjects`, 'affiliations', ...
72
- parent_id = db.Column(db.String, primary_key=True)
73
- name = db.Column(db.String)
74
- uri = db.Column(db.String)
72
+ parent_id = db.Column(db.String(255), primary_key=True)
73
+ name = db.Column(db.String(255))
74
+ uri = db.Column(db.String(255))
75
75
  # Any extra metadata is added as columns.
76
76
 
77
77
  @classmethod
@@ -79,9 +79,7 @@ class VocabularyScheme(db.Model):
79
79
  """Create a new vocabulary subtype."""
80
80
  banned = [",", ":"]
81
81
  for b in banned:
82
- assert (
83
- b not in data["id"]
84
- ), f"No '{b}' allowed in VocabularyScheme.id" # noqa
82
+ assert b not in data["id"], f"No '{b}' allowed in VocabularyScheme.id"
85
83
 
86
84
  with db.session.begin_nested():
87
85
  obj = cls(**data)
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2021 CERN.
3
+ # Copyright (C) 2021-2024 CERN.
4
4
  #
5
5
  # Invenio-Vocabularies is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the MIT License; see LICENSE file for more
@@ -8,7 +8,6 @@
8
8
 
9
9
  """Persistent identifier provider for vocabularies."""
10
10
 
11
-
12
11
  from invenio_pidstore.models import PIDStatus
13
12
  from invenio_pidstore.providers.base import BaseProvider
14
13
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2022 CERN.
3
+ # Copyright (C) 2022-2024 CERN.
4
4
  #
5
5
  # Invenio-Records-Resources is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the MIT License; see LICENSE file for more
@@ -38,7 +38,7 @@ class CustomFieldsRelation(RelationsField):
38
38
  relations[cf.name] = cf.relation_cls(
39
39
  f"custom_fields.{cf.name}",
40
40
  keys=cf.field_keys,
41
- pid_field=Vocabulary.pid.with_type_ctx(cf.vocabulary_id),
41
+ pid_field=cf.pid_field,
42
42
  cache_key=cf.vocabulary_id,
43
43
  )
44
44
 
@@ -1,15 +1,23 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2020-2021 CERN.
3
+ # Copyright (C) 2020-2024 CERN.
4
4
  #
5
5
  # Invenio-Vocabularies is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the MIT License; see LICENSE file for more
7
7
  # details.
8
8
 
9
9
  """Resources module."""
10
+
10
11
  from invenio_vocabularies.resources.schema import L10NString, VocabularyL10Schema
11
12
 
13
+ from .config import VocabulariesResourceConfig, VocabularyTypeResourceConfig
14
+ from .resource import VocabulariesAdminResource, VocabulariesResource
15
+
12
16
  __all__ = (
13
17
  "VocabularyL10Schema",
14
18
  "L10NString",
19
+ "VocabulariesResourceConfig",
20
+ "VocabularyTypeResourceConfig",
21
+ "VocabulariesAdminResource",
22
+ "VocabulariesResource",
15
23
  )
@@ -0,0 +1,105 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2024 CERN.
4
+ # Copyright (C) 2024 University of Münster.
5
+ #
6
+ # Invenio-Vocabularies is free software; you can redistringibute it and/or modify it
7
+ # under the terms of the MIT License; see LICENSE file for more details.
8
+
9
+ """Resources config."""
10
+
11
+ import marshmallow as ma
12
+ from flask_resources import (
13
+ BaseListSchema,
14
+ HTTPJSONException,
15
+ JSONSerializer,
16
+ MarshmallowSerializer,
17
+ ResourceConfig,
18
+ ResponseHandler,
19
+ create_error_handler,
20
+ )
21
+ from invenio_records_resources.resources import (
22
+ RecordResource,
23
+ RecordResourceConfig,
24
+ SearchRequestArgsSchema,
25
+ )
26
+ from invenio_records_resources.resources.errors import ErrorHandlersMixin
27
+ from invenio_records_resources.resources.records.args import SearchRequestArgsSchema
28
+ from invenio_records_resources.resources.records.headers import etag_headers
29
+ from invenio_records_resources.services.base.config import ConfiguratorMixin
30
+
31
+ from .serializer import VocabularyL10NItemSchema
32
+
33
+
34
+ class VocabularySearchRequestArgsSchema(SearchRequestArgsSchema):
35
+ """Vocabularies search request parameters."""
36
+
37
+ tags = ma.fields.Str()
38
+ active = ma.fields.Boolean()
39
+ status = ma.fields.Boolean()
40
+
41
+
42
+ class VocabulariesResourceConfig(RecordResourceConfig):
43
+ """Vocabulary resource configuration."""
44
+
45
+ blueprint_name = "vocabularies"
46
+ url_prefix = "/vocabularies"
47
+ routes = {
48
+ "list": "/<type>",
49
+ "item": "/<type>/<pid_value>",
50
+ "tasks": "/tasks",
51
+ }
52
+
53
+ request_view_args = {
54
+ "pid_value": ma.fields.Str(),
55
+ "type": ma.fields.Str(required=True),
56
+ }
57
+
58
+ request_search_args = VocabularySearchRequestArgsSchema
59
+
60
+ response_handlers = {
61
+ "application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
62
+ "application/vnd.inveniordm.v1+json": ResponseHandler(
63
+ MarshmallowSerializer(
64
+ format_serializer_cls=JSONSerializer,
65
+ object_schema_cls=VocabularyL10NItemSchema,
66
+ list_schema_cls=BaseListSchema,
67
+ ),
68
+ headers=etag_headers,
69
+ ),
70
+ }
71
+
72
+
73
+ class VocabularyTypeResourceConfig(ResourceConfig, ConfiguratorMixin):
74
+ """Vocabulary list resource config."""
75
+
76
+ # /vocabulary/vocabulary_id
77
+ # Blueprint configuration
78
+ blueprint_name = "vocabulary_types"
79
+ url_prefix = "/vocabularies"
80
+
81
+ routes = {"list": "/"}
82
+
83
+ # Request parsing
84
+ request_read_args = {}
85
+ request_view_args = {
86
+ "pid_value": ma.fields.String,
87
+ "type": ma.fields.String,
88
+ }
89
+ request_search_args = VocabularySearchRequestArgsSchema
90
+
91
+ error_handlers = {
92
+ **ErrorHandlersMixin.error_handlers,
93
+ # TODO: Add custom error handlers here
94
+ }
95
+ response_handlers = {
96
+ "application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
97
+ "application/vnd.inveniordm.v1+json": ResponseHandler(
98
+ MarshmallowSerializer(
99
+ format_serializer_cls=JSONSerializer,
100
+ object_schema_cls=VocabularyL10NItemSchema,
101
+ list_schema_cls=BaseListSchema,
102
+ ),
103
+ headers=etag_headers,
104
+ ),
105
+ }
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2020-2021 CERN.
3
+ # Copyright (C) 2020-2024 CERN.
4
+ # Copyright (C) 2024 Uni Münster.
4
5
  #
5
6
  # Invenio-Vocabularies is free software; you can redistribute it and/or
6
7
  # modify it under the terms of the MIT License; see LICENSE file for more
@@ -8,6 +9,8 @@
8
9
 
9
10
  """Vocabulary resource."""
10
11
 
12
+ import json
13
+
11
14
  import marshmallow as ma
12
15
  from flask import g
13
16
  from flask_resources import (
@@ -18,6 +21,7 @@ from flask_resources import (
18
21
  resource_requestctx,
19
22
  response_handler,
20
23
  )
24
+ from invenio_access.permissions import system_identity
21
25
  from invenio_records_resources.resources import (
22
26
  RecordResource,
23
27
  RecordResourceConfig,
@@ -37,55 +41,20 @@ from marshmallow import fields
37
41
  from .serializer import VocabularyL10NItemSchema
38
42
 
39
43
 
40
- #
41
- # Request args
42
- #
43
- class VocabularySearchRequestArgsSchema(SearchRequestArgsSchema):
44
- """Add parameter to parse tags."""
45
-
46
- tags = fields.Str()
47
-
48
-
49
- #
50
- # Resource config
51
- #
52
- class VocabulariesResourceConfig(RecordResourceConfig):
53
- """Vocabulary resource configuration."""
54
-
55
- blueprint_name = "vocabularies"
56
- url_prefix = "/vocabularies"
57
- routes = {"list": "/<type>", "item": "/<type>/<pid_value>", "tasks": "/tasks"}
58
-
59
- request_view_args = {
60
- "pid_value": ma.fields.Str(),
61
- "type": ma.fields.Str(required=True),
62
- }
63
-
64
- request_search_args = VocabularySearchRequestArgsSchema
65
-
66
- response_handlers = {
67
- "application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
68
- "application/vnd.inveniordm.v1+json": ResponseHandler(
69
- MarshmallowSerializer(
70
- format_serializer_cls=JSONSerializer,
71
- object_schema_cls=VocabularyL10NItemSchema,
72
- list_schema_cls=BaseListSchema,
73
- ),
74
- headers=etag_headers,
75
- ),
76
- }
77
-
78
-
79
44
  #
80
45
  # Resource
81
46
  #
82
47
  class VocabulariesResource(RecordResource):
83
- """Resource for generic vocabularies."""
48
+ """Resource for generic vocabularies.
49
+
50
+ Provide the API /api/vocabularies/
51
+ """
84
52
 
85
53
  def create_url_rules(self):
86
54
  """Create the URL rules for the record resource."""
87
55
  routes = self.config.routes
88
56
  rules = super().create_url_rules()
57
+
89
58
  rules.append(
90
59
  route("POST", routes["tasks"], self.launch),
91
60
  )
@@ -164,3 +133,24 @@ class VocabulariesResource(RecordResource):
164
133
  """Create a task."""
165
134
  self.service.launch(g.identity, resource_requestctx.data or {})
166
135
  return "", 202
136
+
137
+
138
+ class VocabulariesAdminResource(RecordResource):
139
+ """Resource for vocabularies admin interface."""
140
+
141
+ def create_url_rules(self):
142
+ """Create the URL rules for the record resource."""
143
+ routes = self.config.routes
144
+
145
+ rules = [route("GET", routes["list"], self.search)]
146
+
147
+ return rules
148
+
149
+ @request_search_args
150
+ @response_handler(many=True)
151
+ def search(self):
152
+ """Return information about _all_ vocabularies."""
153
+ identity = g.identity
154
+ hits = self.service.search(identity, params=resource_requestctx.args)
155
+
156
+ return hits.to_dict(), 200
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2020-2021 CERN.
3
+ # Copyright (C) 2020-2024 CERN.
4
4
  # Copyright (C) 2021 Northwestern University.
5
5
  #
6
6
  # Invenio-Vocabularies is free software; you can redistribute it and/or
@@ -8,6 +8,7 @@
8
8
  # details.
9
9
 
10
10
  """Vocabulary resource schema."""
11
+
11
12
  from marshmallow import Schema, fields
12
13
 
13
14
  from invenio_vocabularies.resources.serializer import L10NString
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2020-2021 CERN.
3
+ # Copyright (C) 2020-2024 CERN.
4
4
  #
5
5
  # Invenio-Vocabularies is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the MIT License; see LICENSE file for more
@@ -8,9 +8,12 @@
8
8
 
9
9
  """Services module."""
10
10
 
11
- from .service import VocabulariesService, VocabulariesServiceConfig
11
+ from .config import VocabulariesServiceConfig, VocabularyTypesServiceConfig
12
+ from .service import VocabulariesService, VocabularyTypeService
12
13
 
13
14
  __all__ = (
14
15
  "VocabulariesService",
16
+ "VocabularyTypeService",
15
17
  "VocabulariesServiceConfig",
18
+ "VocabularyTypesServiceConfig",
16
19
  )
@@ -0,0 +1,179 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2024 CERN.
4
+ # Copyright (C) 2024 University of Münster.
5
+ #
6
+ # Invenio-Vocabularies is free software; you can redistribute it and/or
7
+ # modify it under the terms of the MIT License; see LICENSE file for more
8
+ # details.
9
+
10
+ """Vocabulary services configs."""
11
+
12
+ import sqlalchemy as sa
13
+ from flask import current_app
14
+ from invenio_i18n import lazy_gettext as _
15
+ from invenio_records_resources.services import (
16
+ Link,
17
+ LinksTemplate,
18
+ RecordService,
19
+ RecordServiceConfig,
20
+ SearchOptions,
21
+ pagination_links,
22
+ )
23
+ from invenio_records_resources.services.base import (
24
+ ConditionalLink,
25
+ Service,
26
+ ServiceListResult,
27
+ )
28
+ from invenio_records_resources.services.records.components import DataComponent
29
+ from invenio_records_resources.services.records.params import (
30
+ FilterParam,
31
+ SuggestQueryParser,
32
+ )
33
+
34
+ from ..records.api import Vocabulary
35
+ from ..records.models import VocabularyType
36
+ from . import results
37
+ from .components import PIDComponent, VocabularyTypeComponent
38
+ from .permissions import PermissionPolicy
39
+ from .schema import TaskSchema, VocabularySchema
40
+
41
+
42
+ def is_custom_vocabulary_type(vocabulary_type, context):
43
+ """Check if the vocabulary type is a custom vocabulary type."""
44
+ return vocabulary_type["id"] in current_app.config.get(
45
+ "VOCABULARIES_CUSTOM_VOCABULARY_TYPES", []
46
+ )
47
+
48
+
49
+ class VocabularySearchOptions(SearchOptions):
50
+ """Search options for vocabularies."""
51
+
52
+ params_interpreters_cls = [
53
+ FilterParam.factory(param="tags", field="tags"),
54
+ ] + SearchOptions.params_interpreters_cls
55
+
56
+ suggest_parser_cls = SuggestQueryParser.factory(
57
+ fields=[
58
+ "id.text^100",
59
+ "id.text._2gram",
60
+ "id.text._3gram",
61
+ "title.en^5",
62
+ "title.en._2gram",
63
+ "title.en._3gram",
64
+ ],
65
+ )
66
+
67
+ sort_default = "bestmatch"
68
+
69
+ sort_default_no_query = "title"
70
+
71
+ sort_options = {
72
+ "bestmatch": dict(
73
+ title=_("Best match"),
74
+ fields=["_score"], # ES defaults to desc on `_score` field
75
+ ),
76
+ "title": dict(
77
+ title=_("Title"),
78
+ fields=["title_sort"],
79
+ ),
80
+ "newest": dict(
81
+ title=_("Newest"),
82
+ fields=["-created"],
83
+ ),
84
+ "oldest": dict(
85
+ title=_("Oldest"),
86
+ fields=["created"],
87
+ ),
88
+ }
89
+
90
+
91
+ class VocabularyTypeSearchOptions(SearchOptions):
92
+ """Search options for vocabulary types."""
93
+
94
+ sort_options = {
95
+ "id": dict(
96
+ title=_("ID"),
97
+ fields=["id"],
98
+ ),
99
+ }
100
+
101
+ sort_default = "id"
102
+
103
+ sort_default_no_query = "id"
104
+
105
+ sort_direction_options = {
106
+ "asc": dict(title=_("Ascending"), fn=sa.asc),
107
+ "desc": dict(title=_("Descending"), fn=sa.desc),
108
+ }
109
+
110
+ sort_direction_default = "asc"
111
+
112
+
113
+ class VocabulariesServiceConfig(RecordServiceConfig):
114
+ """Vocabulary service configuration."""
115
+
116
+ service_id = "vocabularies"
117
+ indexer_queue_name = "vocabularies"
118
+ permission_policy_cls = PermissionPolicy
119
+ record_cls = Vocabulary
120
+ schema = VocabularySchema
121
+ task_schema = TaskSchema
122
+
123
+ search = VocabularySearchOptions
124
+
125
+ components = [
126
+ # Order of components are important!
127
+ VocabularyTypeComponent,
128
+ DataComponent,
129
+ PIDComponent,
130
+ ]
131
+
132
+ links_item = {
133
+ "self": Link(
134
+ "{+api}/vocabularies/{type}/{id}",
135
+ vars=lambda record, vars: vars.update(
136
+ {
137
+ "id": record.pid.pid_value,
138
+ "type": record.type.id,
139
+ }
140
+ ),
141
+ ),
142
+ }
143
+
144
+ links_search = pagination_links("{+api}/vocabularies/{type}{?args*}")
145
+
146
+
147
+ class VocabularyTypesServiceConfig(RecordServiceConfig):
148
+ """Vocabulary types service configuration."""
149
+
150
+ service_id = "vocabulary_types"
151
+ permission_policy_cls = PermissionPolicy
152
+ record_cls = VocabularyType
153
+ schema = VocabularySchema # Works but should be VocabularyTypeSchema if this is defined at some point
154
+ result_list_cls = results.VocabularyTypeList
155
+
156
+ links_item = {
157
+ "self": ConditionalLink(
158
+ cond=is_custom_vocabulary_type,
159
+ if_=Link(
160
+ "{+api}/{id}",
161
+ vars=lambda vocab_type, vars: vars.update({"id": vocab_type["id"]}),
162
+ ),
163
+ else_=Link(
164
+ "{+api}/vocabularies/{id}",
165
+ vars=lambda vocab_type, vars: vars.update({"id": vocab_type["id"]}),
166
+ ),
167
+ )
168
+ }
169
+
170
+ search = VocabularyTypeSearchOptions
171
+
172
+ components = [
173
+ # Order of components are important!
174
+ VocabularyTypeComponent,
175
+ DataComponent,
176
+ PIDComponent,
177
+ ]
178
+
179
+ links_search = pagination_links("{+api}/vocabularies/{type}{?args*}")
@@ -1,12 +1,16 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2022 CERN.
3
+ # Copyright (C) 2022-2024 CERN.
4
4
  #
5
5
  # Invenio-RDM-Records is free software; you can redistribute it and/or modify
6
6
  # it under the terms of the MIT License; see LICENSE file for more details.
7
7
 
8
8
  """Custom Fields for InvenioRDM."""
9
9
 
10
+ from .subject import SUBJECT_FIELDS, SUBJECT_FIELDS_UI
10
11
  from .vocabulary import VocabularyCF
11
12
 
12
- __all__ = "VocabularyCF"
13
+ __all__ = [
14
+ "VocabularyCF",
15
+ "SUBJECT_FIELDS_UI" "SUBJECT_FIELDS",
16
+ ]
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2024 CERN.
4
+ #
5
+ # Invenio-RDM-Records 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
+
9
+ """Custom fields."""
10
+
11
+ from invenio_i18n import lazy_gettext as _
12
+
13
+ from ...contrib.subjects.api import Subject
14
+ from ...contrib.subjects.schema import SubjectRelationSchema
15
+ from .vocabulary import VocabularyCF
16
+
17
+
18
+ class SubjectCF(VocabularyCF):
19
+ """Custom field for subjects."""
20
+
21
+ field_keys = ["id", "subject"]
22
+
23
+ def __init__(self, **kwargs):
24
+ """Constructor."""
25
+ super().__init__(
26
+ vocabulary_id="subjects",
27
+ schema=SubjectRelationSchema,
28
+ ui_schema=SubjectRelationSchema,
29
+ **kwargs,
30
+ )
31
+ self.pid_field = Subject.pid
32
+
33
+ @property
34
+ def mapping(self):
35
+ """Return the mapping."""
36
+ _mapping = {
37
+ "type": "object",
38
+ "properties": {
39
+ "@v": {"type": "keyword"},
40
+ "id": {"type": "keyword"},
41
+ "subject": {"type": "keyword"},
42
+ },
43
+ }
44
+
45
+ return _mapping
46
+
47
+
48
+ SUBJECT_FIELDS_UI = [
49
+ {
50
+ "section": _("Subjects"),
51
+ "fields": [
52
+ dict(
53
+ field="subjects",
54
+ ui_widget="SubjectAutocompleteDropdown",
55
+ isGenericVocabulary=False,
56
+ props=dict(
57
+ label="Keywords and subjects",
58
+ icon="tag",
59
+ description="The subjects related to the community",
60
+ placeholder="Search for a subject by name e.g. Psychology ...",
61
+ autocompleteFrom="api/subjects",
62
+ noQueryMessage="Search for subjects...",
63
+ autocompleteFromAcceptHeader="application/vnd.inveniordm.v1+json",
64
+ required=False,
65
+ multiple=True,
66
+ clearable=True,
67
+ allowAdditions=False,
68
+ ),
69
+ template="invenio_vocabularies/subjects.html",
70
+ )
71
+ ],
72
+ }
73
+ ]
74
+
75
+
76
+ SUBJECT_FIELDS = {
77
+ SubjectCF(
78
+ name="subjects",
79
+ multiple=True,
80
+ dump_options=False,
81
+ )
82
+ }