diff --git a/modules/bibformat/lib/elements/bfe_contact_lab.py b/modules/bibformat/lib/elements/bfe_contact_lab.py index f73ce3da7..f3e74f1e5 100755 --- a/modules/bibformat/lib/elements/bfe_contact_lab.py +++ b/modules/bibformat/lib/elements/bfe_contact_lab.py @@ -1,43 +1,54 @@ # -*- coding: utf-8 -*- """BibFormat element - Prints link to lab""" from invenio.messages import gettext_set_language def format(bfo, kb_name, kb_url): """ Prints the contact informations. Translate using given knowledge base. @param kb_name a knowledge base use to translate the lab identifier @param kb_url a knowledge base use to translate the lab identifier - """ - lab_identifiers = bfo.fields("909C0p", escape=2) + """ out = [] + lab_identifiers = bfo.fields("909C0p", escape=2) + + # first check if we are in tto mode, as it has his own rules + is_tto = False + + if 'TTO' in lab_identifiers: + is_tto = True + else: + # check in source origin + external_ids = bfo.fields('035__a') + + for field in external_ids: + if 'TTO' in field: + is_tto = True + + if bfo.field('980__a') == 'PATENT' and is_tto: + out.append('Technology Transfer Office') + + # normal step for all laboratories for lab in lab_identifiers: + if lab == 'TTO': + # already done + continue + lab_name = bfo.kb(kb_name, lab) lab_url = bfo.kb(kb_url, lab) if lab_url: out.append('%s' % (lab_url, lab_name)) else: out.append('%s' % lab_name) - # Add the TTO if we have a patent - is_tto = False - - external_ids = bfo.fields('035__a') - - for field in external_ids: - if 'TTO' in field: - is_tto = True - - if bfo.field('980__a') == 'PATENT' and is_tto: - out.append('Technology Transfer Office') return ''.join(['
  • %s
  • ' % elem for elem in out]) def escape_values(bfo): """ Called by BibFormat in order to check if output of this element should be escaped. """ return 0