Skip to content

Commit

Permalink
[#224] Fix bug where Cordaid is field partner
Browse files Browse the repository at this point in the history
When Cordaid is a field partner to a project two partnership objects get
the same internal ID and IATI activity ID. Fix by only allowing support
partners to have internal ID.
  • Loading branch information
zzgvh committed Aug 14, 2013
1 parent 5ff9dba commit 80e43a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion akvo/api/resources/partnership.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
FIELD_NAME = 'name'
FIELD_LONG_NAME = 'long_name'
FIELD_NEW_ORGANISATION_TYPE = 'new_organisation_type'
FIELD_PARTNER_TYPE = 'partner_type'
ORG_FIELDS = [FIELD_IATI_ORG_ID, FIELD_NAME, FIELD_LONG_NAME, FIELD_NEW_ORGANISATION_TYPE]
# InternalOrganisationID
FIELD_INTERNAL_ORG_ID = 'internal_org_id'
Expand Down Expand Up @@ -171,7 +172,10 @@ def hydrate(self, bundle):
organisation = get_organisation(bundle)
if organisation:
bundle.data[FIELD_ORGANISATION] = organisation
if organisation.iati_org_id != bundle.data[FIELD_REPORTING_ORG]:
if (
organisation.iati_org_id != bundle.data[FIELD_REPORTING_ORG] or
bundle.data[FIELD_PARTNER_TYPE] != Partnership.SUPPORT_PARTNER
):
bundle.data[FIELD_IATI_ACTIVITY_ID] = None
bundle.data[FIELD_INTERNAL_ID] = None
else:
Expand Down
4 changes: 2 additions & 2 deletions akvo/scripts/cordaid/cordaid_project_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from akvo import settings
setup_environ(settings)

from akvo.scripts.cordaid import log, API_VERSION, CORDAID_IATI_ACTIVITIES_XML, CORDAID_UPLOAD_CSV_FILE, ACTION_CREATE_PROJECT, ERROR_EXCEPTION, ERROR_UPLOAD_ACTIVITY, ERROR_CREATE_ACTIVITY, ERROR_UPDATE_ACTIVITY, ACTION_UPDATE_PROJECT, CORDAID_ACTIVITIES_CSV_FILE, print_log, init_log
from akvo.scripts.cordaid import log, API_VERSION, CORDAID_IATI_ACTIVITIES_XML, CORDAID_UPLOAD_CSV_FILE, ACTION_CREATE_PROJECT, ERROR_EXCEPTION, ERROR_UPLOAD_ACTIVITY, ERROR_CREATE_ACTIVITY, ERROR_UPDATE_ACTIVITY, ACTION_UPDATE_PROJECT, CORDAID_ACTIVITIES_CSV_FILE, print_log, init_log, ERROR_MULTIPLE_OBJECTS
from requester import Requester


Expand Down Expand Up @@ -212,7 +212,7 @@ def upload_activities(argv):
log(message, data)
print message.format(**data)
elif project_count > 1:
data = dict(iati_id=iati_id, extra=internal_id)
data = dict(iati_id=iati_id, event=ERROR_MULTIPLE_OBJECTS, extra=internal_id)
log(None, data)
print(
"**** Error updating iati-activity: {iati_id}. "
Expand Down

0 comments on commit 80e43a6

Please sign in to comment.