From b1810d6677030f832f8fcf7e22be2b71176c2cf7 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Thu, 20 Aug 2015 10:24:41 +0300 Subject: [PATCH] [#1749] Check if partnership has organisation in IATI export --- akvo/iati/elements/participating_org.py | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/akvo/iati/elements/participating_org.py b/akvo/iati/elements/participating_org.py index 925320726f..57bfb80c7d 100644 --- a/akvo/iati/elements/participating_org.py +++ b/akvo/iati/elements/participating_org.py @@ -25,24 +25,25 @@ def participating_org(project): for partnership in project.partnerships.all(): org = partnership.organisation - element = etree.Element("participating-org") + if org: + element = etree.Element("participating-org") - if org.iati_org_id: - element.attrib['ref'] = org.iati_org_id + if org.iati_org_id: + element.attrib['ref'] = org.iati_org_id - if org.new_organisation_type: - element.attrib['type'] = str(org.new_organisation_type) + if org.new_organisation_type: + element.attrib['type'] = str(org.new_organisation_type) - if partnership.partner_type in TYPE_TO_CODE.keys(): - element.attrib['role'] = TYPE_TO_CODE[partnership.partner_type] + if partnership.partner_type in TYPE_TO_CODE.keys(): + element.attrib['role'] = TYPE_TO_CODE[partnership.partner_type] - narrative_element = etree.SubElement(element, "narrative") + narrative_element = etree.SubElement(element, "narrative") - if org.long_name: - narrative_element.text = org.long_name - elif org.name: - narrative_element.text = org.name + if org.long_name: + narrative_element.text = org.long_name + elif org.name: + narrative_element.text = org.name - partnership_elements.append(element) + partnership_elements.append(element) return partnership_elements