Skip to content

Commit

Permalink
[Fixes #2189] Updates to IATI import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
damienallen committed May 26, 2016
1 parent 9521304 commit 191d4c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion akvo/iati/checks/fields/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def status(project):
:param project: Project object
:return: All checks passed boolean, [Check results]
"""
if project.status:
if project.iati_status:
return True, [(u'success', u'has status')]

else:
Expand Down
6 changes: 3 additions & 3 deletions akvo/iati/exports/elements/activity_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from lxml import etree

STATUS_TO_CODE = {
'N': '6',
'N': '0',
'H': '1',
'A': '2',
'C': '3',
Expand All @@ -23,9 +23,9 @@ def activity_status(project):
:param project: Project object
:return: A list of Etree elements
"""
if project.status in STATUS_TO_CODE.keys():
if project.iati_status:
element = etree.Element("activity-status")
element.attrib['code'] = STATUS_TO_CODE[project.status]
element.attrib['code'] = project.iati_status
return [element]

return []
6 changes: 2 additions & 4 deletions akvo/iati/imports/mappers/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,9 @@ def do_import(self):
status = self.get_child_elem_attrib(
self.parent_elem, 'activity-status', 'code', 'status')

if status in CODE_TO_STATUS.keys():
status = CODE_TO_STATUS[status]
else:
if not status:
self.add_log('activity-status@code', 'status', 'invalid status code')
status = Project.STATUS_NONE
status = 0

return self.update_project_field('status', status)

Expand Down

0 comments on commit 191d4c8

Please sign in to comment.