Skip to content

Commit

Permalink
documents: fill out custom fields for ROAR during RERO DOC import
Browse files Browse the repository at this point in the history
* Adds specific transformation to RERO DOC import for ROAR,
  in order to fill out custom fields `Filière` (`customField1`)
  and `Titre obtenu` (`customField2`).
* Fixes bug in customField facet label definition.
* Fixes typo in FREDI description.

Co-Authored-by: Miguel Moreira <miguel.moreira@rero.ch>
  • Loading branch information
mmo authored and jma committed Nov 2, 2021
1 parent 2463ff8 commit 9978630
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sonar/dedicated/templates/dedicated/hepvs/home.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p>FREDI est l'acronyme de "Forschung – Recherche – Entwicklung – Développement – Innova(z)tion" la nouvelle
<p>FREDI est l'acronyme de "Forschung – Recherche – Entwicklung – Développement – Innovation" la nouvelle
plateforme de dépôt des productions scientifiques et professionnelles en Open Access ainsi que des projets de
recherche de la Haute école pédagogique du Valais. De plus, selon la logique d'amélioration continue, la plateforme
FREDI permet de centraliser l'intégralité des données des projets de recherche à des fins d'optimisation du système
Expand Down
18 changes: 18 additions & 0 deletions sonar/modules/documents/dojson/rerodoc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ def marc21_to_type_and_organisation(self, key, value):
if organisation == 'unisi':
organisation = 'usi'

# Specific transformation for `hep bejune`, in order to fill out
# custom fields `Filière` (`customField1`) and `Titre obtenu`
# (`customField2`)
if organisation == 'hepbejune' and value.get('f'):
document_subtype = value.get('f').lower()
customField1 = ''
customField2 = ''
if document_subtype == 'diss_bachelor':
customField1 = 'Enseignement primaire'
customField2 = 'Bachelor of Arts in Pre-Primary and Primary Education'
elif document_subtype == 'diss_master':
customField1 = 'Enseignement secondaire'
customField2 = 'Master of Arts or of Science in Secondary Education'
if customField1:
self['customField1'] = [customField1]
if customField2:
self['customField2'] = [customField2]

# Specific transformation for `bpuge` and `mhnge`, because the real
# acronym is `vge`.
subdivision_name = None
Expand Down
3 changes: 3 additions & 0 deletions sonar/modules/documents/loaders/schemas/rerodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class RerodocSchema(Marc21Schema):
usageAndAccessPolicy = fields.Dict()
files = fields.List(fields.Dict())
subdivisions = fields.List(fields.Dict())
customField1 = fields.List(fields.String())
customField2 = fields.List(fields.String())
customField3 = fields.List(fields.String())

@pre_dump
def process(self, obj, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion sonar/modules/documents/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def aggregations():
aggregations_list[aggregations_list.index(
f'customField{i}')] = {
'key':
f'customField{1}',
f'customField{i}',
'name':
get_language_value(
organisation[f'documentsCustomField{i}']['label'])
Expand Down

0 comments on commit 9978630

Please sign in to comment.