diff --git a/akvo/iati/checks/v201.py b/akvo/iati/checks/v201.py index 96f7c13009..2f542305b7 100644 --- a/akvo/iati/checks/v201.py +++ b/akvo/iati/checks/v201.py @@ -624,8 +624,9 @@ def results(self): u'specified' % str(result.pk))) if not result.title: - checks.append((u'warning', u'result (id: %s) has no title ' - u'specified' % str(result.pk))) + self.all_checks_passed = False + checks.append((u'error', u'result (id: %s) has no title ' + u'specified' % str(result.pk))) if not result.indicators.all() and not result.description: self.all_checks_passed = False @@ -634,12 +635,14 @@ def results(self): for indicator in result.indicators.all(): if not indicator.measure: - checks.append((u'warning', u'indicator (id: %s) has no measure ' - u'specified' % str(indicator.pk))) + self.all_checks_passed = False + checks.append((u'error', u'indicator (id: %s) has no measure ' + u'specified' % str(indicator.pk))) if not indicator.title: - checks.append((u'warning', u'indicator (id: %s) has no title ' - u'specified' % str(indicator.pk))) + self.all_checks_passed = False + checks.append((u'error', u'indicator (id: %s) has no title ' + u'specified' % str(indicator.pk))) if (indicator.baseline_value and not indicator.baseline_year) or \ (not indicator.baseline_value and indicator.baseline_year): diff --git a/akvo/iati/elements/document_link.py b/akvo/iati/elements/document_link.py index a71b0c55ff..9b7ea7b8cf 100644 --- a/akvo/iati/elements/document_link.py +++ b/akvo/iati/elements/document_link.py @@ -21,9 +21,10 @@ def document_link(project): current_image_element.attrib['url'] = "http://rsr.akvo.org" + project.current_image.url current_image_element.attrib['format'] = "image/jpeg" + title_element = etree.SubElement(current_image_element, "title") + narrative_element = etree.SubElement(title_element, "narrative") + if project.current_image_caption or project.current_image_credit: - title_element = etree.SubElement(current_image_element, "title") - narrative_element = etree.SubElement(title_element, "narrative") if project.current_image_caption and project.current_image_credit: narrative_element.text = "%s, credit: %s" % ( project.current_image_caption, @@ -33,6 +34,8 @@ def document_link(project): narrative_element.text = project.current_image_caption elif project.current_image_credit: narrative_element.text = "Credit: %s" % (project.current_image_credit,) + else: + narrative_element.text = "Project photo" category_element = etree.SubElement(current_image_element, "category") category_element.attrib['code'] = "A12" @@ -45,10 +48,9 @@ def document_link(project): link_element.attrib['url'] = link.url link_element.attrib['format'] = "application/http" - if link.caption: - title_element = etree.SubElement(link_element, "title") - narrative_element = etree.SubElement(title_element, "narrative") - narrative_element.text = link.caption + title_element = etree.SubElement(link_element, "title") + narrative_element = etree.SubElement(title_element, "narrative") + narrative_element.text = link.caption if link.caption else "Project link" category_element = etree.SubElement(link_element, "category") category_element.attrib['code'] = "A12" @@ -67,10 +69,9 @@ def document_link(project): if document.format: document_element.attrib['format'] = document.format - if document.title: - title_element = etree.SubElement(document_element, "title") - narrative_element = etree.SubElement(title_element, "narrative") - narrative_element.text = document.title + title_element = etree.SubElement(document_element, "title") + narrative_element = etree.SubElement(title_element, "narrative") + narrative_element.text = document.title if document.title else "Project document" if document.category: category_element = etree.SubElement(document_element, "category") @@ -87,10 +88,9 @@ def document_link(project): update_element.attrib['url'] = "http://rsr.akvo.org/project/%s/update/%s/" % (str(project.pk), str(update.pk)) update_element.attrib['format'] = "application/http" - if update.title: - title_element = etree.SubElement(update_element, "title") - narrative_element = etree.SubElement(title_element, "narrative") - narrative_element.text = update.title + title_element = etree.SubElement(update_element, "title") + narrative_element = etree.SubElement(title_element, "narrative") + narrative_element.text = update.title if update.title else "Project update" category_element = etree.SubElement(update_element, "category") category_element.attrib['code'] = "A12" diff --git a/akvo/iati/elements/reporting_org.py b/akvo/iati/elements/reporting_org.py index cf148b57cc..be874b9f42 100644 --- a/akvo/iati/elements/reporting_org.py +++ b/akvo/iati/elements/reporting_org.py @@ -22,7 +22,7 @@ def reporting_org(project): element.attrib['ref'] = org.iati_org_id if project.sync_owner_secondary_reporter is not None: - element.attrib['secondary_reporter'] = '1' if project.sync_owner_secondary_reporter else '0' + element.attrib['secondary-reporter'] = '1' if project.sync_owner_secondary_reporter else '0' if org.new_organisation_type: element.attrib['type'] = str(org.new_organisation_type) diff --git a/akvo/iati/elements/sector.py b/akvo/iati/elements/sector.py index 0c6056ed0f..a05bd2f16f 100644 --- a/akvo/iati/elements/sector.py +++ b/akvo/iati/elements/sector.py @@ -31,9 +31,6 @@ def sector(project): if sec.percentage: element.attrib['percentage'] = str(sec.percentage) - if sec.text: - element.text = sec.text - sector_elements.append(element) return sector_elements diff --git a/akvo/rsr/forms.py b/akvo/rsr/forms.py index 1cbc157a20..d05c3e3c3e 100644 --- a/akvo/rsr/forms.py +++ b/akvo/rsr/forms.py @@ -394,10 +394,18 @@ def __init__(self, user, *args, **kwargs): ) +class CustomLabelModelChoiceField(forms.ModelMultipleChoiceField): + def label_from_instance(self, obj): + if obj.is_published(): + return mark_safe(u'%s' % obj.__unicode__()) + else: + return mark_safe(u'%s (not published)' % obj.__unicode__()) + + class IatiExportForm(forms.ModelForm): """Form for adding an entry to the IATI export model.""" is_public = forms.BooleanField(required=False, label=_(u"Show IATI file on organisation page")) - projects = forms.ModelMultipleChoiceField( + projects = CustomLabelModelChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Project.objects.all(), label=_(u"Select the projects included in the export:") diff --git a/akvo/rsr/static/scripts-src/my-iati.js b/akvo/rsr/static/scripts-src/my-iati.js index b11d950270..96b32d82ac 100644 --- a/akvo/rsr/static/scripts-src/my-iati.js +++ b/akvo/rsr/static/scripts-src/my-iati.js @@ -36,12 +36,13 @@ function loadAsync(url, retryCount, retryLimit, label) { } function processResponse(label, response) { - var label_content, checks, all_checks_passed, span; + var label_content, checks, all_checks_passed, span, checks_response; - label_content = label.innerHTML; + label_content = label.innerHTML.replace("noCheck", ""); checks = JSON.parse(response); all_checks_passed = checks.all_checks_passed; + checks_response = checks.checks; if (all_checks_passed === "True") { span = document.createElement("span"); @@ -51,9 +52,15 @@ function processResponse(label, response) { label.innerHTML = ''; label.appendChild(span); - } else if (all_checks_passed === "False") { + } else { span = document.createElement("span"); span.className = "error"; + label_content += "
"; + for (var i = 0; i < checks_response.length; i++) { + if (checks_response[i][0] === "error") { + label_content += "- " + checks_response[i][1] + "
"; + } + } span.innerHTML = label_content; label.innerHTML = ''; diff --git a/akvo/rsr/static/scripts-src/my-iati.jsx b/akvo/rsr/static/scripts-src/my-iati.jsx index efb8374f8c..5f10965225 100644 --- a/akvo/rsr/static/scripts-src/my-iati.jsx +++ b/akvo/rsr/static/scripts-src/my-iati.jsx @@ -36,12 +36,13 @@ function loadAsync(url, retryCount, retryLimit, label) { } function processResponse(label, response) { - var label_content, checks, all_checks_passed, span; + var label_content, checks, all_checks_passed, span, checks_response; - label_content = label.innerHTML; + label_content = label.innerHTML.replace("noCheck", ""); checks = JSON.parse(response); all_checks_passed = checks.all_checks_passed; + checks_response = checks.checks; if (all_checks_passed === "True") { span = document.createElement("span"); @@ -51,9 +52,15 @@ function processResponse(label, response) { label.innerHTML = ''; label.appendChild(span); - } else if (all_checks_passed === "False") { + } else { span = document.createElement("span"); span.className = "error"; + label_content += "
"; + for (var i = 0; i < checks_response.length; i++) { + if (checks_response[i][0] === "error") { + label_content += "- " + checks_response[i][1] + "
"; + } + } span.innerHTML = label_content; label.innerHTML = ''; diff --git a/akvo/templates/myrsr/my_iati.html b/akvo/templates/myrsr/my_iati.html index 38b2ee0ccc..66cf120f2f 100644 --- a/akvo/templates/myrsr/my_iati.html +++ b/akvo/templates/myrsr/my_iati.html @@ -7,6 +7,9 @@ {% block head %} {{block.super}}