Skip to content

Commit

Permalink
Send organization: fix description
Browse files Browse the repository at this point in the history
  • Loading branch information
htysc committed Dec 9, 2023
1 parent cb219e6 commit 7e95694
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions backend/services/partnerNetwork/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function updateOrganization(req, res, next) {
}
console.log(JSON.stringify(PredefinedCharacteristics));
organization.fields[PredefinedCharacteristics['Organization Name']._uri.split('#')[1]] = partnerData.organization.name || '';
organization.fields[PredefinedCharacteristics['Description']._uri.split('#')[1]] = partnerData.organization.description || '';
organization.fields[PredefinedCharacteristics['Description']._uri.split('#')[1]] = partnerData.organization.description || partnerData.organization.Description || '';
// organization.fields[PredefinedCharacteristics['Address']._uri.split('#')[1]] = partnerData.organization.address; // TODO
organization.formId = organizationFormId;
console.log(organization);
Expand Down Expand Up @@ -314,7 +314,7 @@ async function getOrganizationAssets(organizationId, assetType, characteristics,

async function sendOrganization(req, res, next) {
try {
const organization = await GDBOrganizationModel.findOne({status: 'Home'}, {populates: ['characteristicOccurrences.occurrenceOf', 'description']});
const organization = await GDBOrganizationModel.findOne({status: 'Home'}, {populates: ['characteristicOccurrences.occurrenceOf']});
if (!organization) {
throw new Error('This deployment has no home organization');
}
Expand All @@ -330,6 +330,16 @@ async function sendOrganization(req, res, next) {
partnerOrganizations = partnerOrganizations
.filter(organizationObj => organizationObj.status === 'Partner' && organizationObj.apiKey === yourApiKey)
.map(organizationObj => organizationObj._uri);

for (characteristicOccurrence of organization.characteristicOccurrences) {
if ('occurrenceOf' in characteristicOccurrence) {
if ('dataStringValue' in characteristicOccurrence) {
organization[characteristicOccurrence.occurrenceOf.description.split(' ').join('_')] = characteristicOccurrence.dataStringValue;
} else if ('dataNumberValue' in characteristicOccurrence) {
organization[characteristicOccurrence.occurrenceOf.description.split(' ').join('_')] = organization[characteristicOccurrence.dataNumberValue]
}
}
}

organization.programs = await getOrganizationAssets(genericId, 'program', {
'Program Name': 'programName',
Expand Down

0 comments on commit 7e95694

Please sign in to comment.