From f17e3397fbbcea2c774ac3f2cb9b8e884b131fc6 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Thu, 27 Jul 2017 19:33:44 +0200 Subject: [PATCH] Debug case of empty custom_metadata --- journals/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/journals/views.py b/journals/views.py index 8e51f7cb1..111eaa593 100644 --- a/journals/views.py +++ b/journals/views.py @@ -588,11 +588,13 @@ def create_metadata_xml(request, doi_label): '<crossmark_domain><domain>scipost.org</domain></crossmark_domain>\n' '</crossmark_domains>\n' '<crossmark_domain_exclusive>false</crossmark_domain_exclusive>\n' - '<custom_metadata>\n' ) funders = (Funder.objects.filter(grant__in=publication.grants.all()) | publication.funders_generic.all()).distinct() nr_funders = funders.count() + need_custom_metadata = nr_funders > 0 # JSC: more conditions to follow later + if need_custom_metadata: + initial['metadata_xml'] += '<custom_metadata>\n' if nr_funders > 0: initial['metadata_xml'] += '<fr:program name="fundref">\n' for funder in funders: @@ -611,9 +613,9 @@ def create_metadata_xml(request, doi_label): if nr_funders > 1: initial['metadata_xml'] += '</fr:assertion>\n' initial['metadata_xml'] += '</fr:program>\n' - + if need_custom_metadata: + initial['metadata_xml'] += '</custom_metadata>\n' initial['metadata_xml'] += ( - '</custom_metadata>\n' '</crossmark>\n' '<archive_locations><archive name="CLOCKSS"></archive></archive_locations>\n' '<doi_data>\n' -- GitLab