Skip to content

Commit

Permalink
Import translation source and note
Browse files Browse the repository at this point in the history
  • Loading branch information
arielpontes committed Jan 11, 2021
1 parent dcd50b7 commit 86ef9cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gemet/thesaurus/import_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,25 @@ def _add_translations(self, sheet):
language = Language.objects.get(code=sheet.title.lower())

en_label = row.get('Term')
translation = row.get('Target language')
definition = row.get('Definition')

if not en_label:
raise ImportError(u'"Term" column cannot be blank.')
translation = row.get('Target language')
definition = row.get('Definition')
source = row.get("Definition source")
note = row.get("Note")
alt_labels = [
row[key] for key in row.keys()
if 'Alt Label' in key and row[key]
]

property_values = {
'prefLabel': translation,
'definition': definition,
'source': source,
'scopeNote': note,
}
if alt_labels:
property_values['altLabel'] = alt_labels

concept = Property.objects.get(
name='prefLabel',
Expand Down
8 changes: 8 additions & 0 deletions gemet/thesaurus/tests/test_import.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from django.core.files import File
from django.db.models import Q
from django.test import TestCase, Client
Expand Down Expand Up @@ -65,6 +66,13 @@ def test_import_concepts_and_translations_together(self):
).count(),
1
)
# In all languages
self.assertEqual(
Property.objects.filter(
name='scopeNote', value=u'Par opposition à la finance verte'
).count(),
1
)
# And multiple altlabels
self.assertEqual(
Property.objects.filter(name='altLabel').filter(
Expand Down

0 comments on commit 86ef9cd

Please sign in to comment.