Repository: akvo/akvo-rsr

Issue:
IATI expects baseline year to be a positiveInteger
N/A values for baseline year are not acceptable, and cause the XML to fail validation.


Discussion:

Resolving patch:
diff --git a/akvo/iati/checks/fields/results.py b/akvo/iati/checks/fields/results.py
--- a/akvo/iati/checks/fields/results.py
+++ b/akvo/iati/checks/fields/results.py
@@ -60,7 +60,7 @@ def results(project):
                 if DGIS_PROJECT:
                     all_checks_passed = False
                     checks.append((u'warning', u'indicator (id: %s) baseline has no year '
-                                               u'specified, however the value of "N/A" has been '
+                                               u'specified, however the value of "1" has been '
                                                u'set for the attribute' % str(indicator.pk)))
                 elif indicator.baseline_value or indicator.baseline_comment:
                     all_checks_passed = False
diff --git a/akvo/iati/exports/elements/result.py b/akvo/iati/exports/elements/result.py
--- a/akvo/iati/exports/elements/result.py
+++ b/akvo/iati/exports/elements/result.py
@@ -10,6 +10,7 @@
 
 DGIS_VALIDATION_SET_NAME = u"DGIS IATI"
 NOT_AVAILABLE = u"N/A"
+NOT_AVAILABLE_YEAR = u"1"
 
 
 def result(project):
@@ -87,7 +88,7 @@ def result(project):
                             if indicator.baseline_year:
                                 baseline_element.attrib['year'] = str(indicator.baseline_year)
                             elif DGIS_PROJECT:
-                                baseline_element.attrib['year'] = NOT_AVAILABLE
+                                baseline_element.attrib['year'] = NOT_AVAILABLE_YEAR
 
                             if indicator.baseline_value:
                                 baseline_element.attrib['value'] = indicator.baseline_value


Test patch:
diff --git a/akvo/rsr/tests/iati_checks/test_iati_checks_fields_results.py b/akvo/rsr/tests/iati_checks/test_iati_checks_fields_results.py
--- a/akvo/rsr/tests/iati_checks/test_iati_checks_fields_results.py
+++ b/akvo/rsr/tests/iati_checks/test_iati_checks_fields_results.py
@@ -113,7 +113,7 @@ def test_iati_checks_fields_results_indicator_dgis_error(self):
         self.assertEquals(u'warning', checks[0][0])
         self.assertIn(u'no value specified, however the value of "N/A"', checks[0][1])
         self.assertEquals(u'warning', checks[1][0])
-        self.assertIn(u'no year specified, however the value of "N/A"', checks[1][1])
+        self.assertIn(u'no year specified, however the value of "1"', checks[1][1])
 
     def test_iati_checks_fields_results_period_pass(self):
         # Given
diff --git a/akvo/rsr/tests/iati_export/test_iati_export.py b/akvo/rsr/tests/iati_export/test_iati_export.py
--- a/akvo/rsr/tests/iati_export/test_iati_export.py
+++ b/akvo/rsr/tests/iati_export/test_iati_export.py
@@ -613,7 +613,7 @@ def test_dgis_validated_project_export(self):
         indicator_baseline_xpath = './iati-activity/result/indicator/baseline'
         self.assertXpathsExist(root_test, (indicator_baseline_xpath,))
         baseline = root_test.xpath(indicator_baseline_xpath)
-        self.assertEqual(baseline[0].attrib["year"], u"N/A")
+        self.assertEqual(baseline[0].attrib["year"], u"1")
         self.assertEqual(baseline[0].attrib["value"], u"N/A")
 
         # Test period has target value