Commit 2180ce2e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[profile gen] Be more resilient about supported concept's languages

Export used to chose concept value by searching for label with the following
language code:

1. version specific (seda-2, seda-1 or seda-02)
2. seda
3. en

and crash if no matching label was found. But it seems we don't want it to crash
because we use some concept which has e.g. only a concept in 'fr' language code.
At some point we may want to improve this, depending on the relation (internal
seda vocabulary vs open vocabulary such as keyword reference), but for now,
let's add 'fr' to the expected language list and fallback to any language if
none has been found so the export doesn't fail.

Related to extranet #15934212
parent 0ae7957cf9e3
......@@ -90,13 +90,12 @@ def _concept_value(concept, language):
assert language in ('seda-2', 'seda-1', 'seda-02')
if concept is None:
return None
for code in (language, 'seda', 'en'):
for code in (language, 'seda', 'en', 'fr'):
return concept.labels[code]
except KeyError:
raise RuntimeError('Concept %s has no preferred label in one of "%s", "seda" or "en" language'
% (concept.eid, language))
return concept.label()
def eid2xmlid(eid):
......@@ -578,7 +578,8 @@ class SEDAExportFuncTCMixIn(object):
with self.admin_access.client_cnx() as cnx:
create = cnx.create_entity
scheme = create('ConceptScheme', title=u'Keyword Types')
some_concept = scheme.add_concept(label=u'md5')
# ensure we're able to export concept with unexpected language code
some_concept = scheme.add_concept(label=u'md5', language_code=u'de')
transfer = create('SEDAArchiveTransfer', title=u'test profile')
......@@ -705,6 +706,9 @@ class OldSEDAExportMixin(object):
scheme = testutils.scheme_for_type(cnx, rtype, etype, value)
concepts[value] = scheme.reverse_in_scheme[0]
# ensure we're able to export concept with unexpected language code
agent = testutils.create_authority_record(cnx, u'bob')
transfer = create('SEDAArchiveTransfer', title=u'my profile title &&',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment