Skip to content

Commit

Permalink
Merge pull request #125 from partio-scout/bugfix/family-camp
Browse files Browse the repository at this point in the history
Bugfix/family camp
  • Loading branch information
googol authored Jul 17, 2016
2 parents 3057a9a + 1ca1dea commit c1fc1c1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/common/models/kuksa-participant.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
"nullable": "YES"
}
},
"accommodation": {
"type": "string",
"required": false,
"postgresql": {
"columnName": "accommodation",
"dataType": "character varying",
"dataLength": 255,
"dataPrecision": null,
"dataScale": null,
"nullable": "YES"
}
},
"cancelled": {
"type": "boolean",
"postgresql": {
Expand Down
12 changes: 12 additions & 0 deletions src/common/models/participant.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@
"nullable": "NO"
}
},
"accommodation": {
"type": "string",
"required": false,
"postgresql": {
"columnName": "accommodation",
"dataType": "character varying",
"dataLength": 255,
"dataPrecision": null,
"dataScale": null,
"nullable": "YES"
}
},
"ageGroup": {
"type": "string",
"required": true,
Expand Down
1 change: 1 addition & 0 deletions src/kuksa-integration/fetch-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function transferParticipants(eventApi) {
subCampId: participant.subCamp,
cancelled: participant.cancelled,
diet: participant.diet,
accommodation: participant.accommodation,
}),
dateRange: daterange,
},
Expand Down
6 changes: 5 additions & 1 deletion src/kuksa-integration/rebuild-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function rebuildParticipantsTable() {
}

function getSubCamp(participant) {
if (getSelectionForGroup(participant, 'Osallistun seuraavan ikäkauden ohjelmaan:') === 'perheleirin ohjelmaan (0-11v.), muistathan merkitä lisätiedot osallistumisesta \"vain perheleirin osallistujille\" -osuuteen.') {
if (participant.accommodation === 'Perheleirissä') {
return 'Riehu';
} else if (getSelectionForGroup(participant, 'Osallistun seuraavan ikäkauden ohjelmaan:') === 'perheleirin ohjelmaan (0-11v.), muistathan merkitä lisätiedot osallistumisesta \"vain perheleirin osallistujille\" -osuuteen.') {
return 'Riehu';
}
return _.get(participant, 'subCamp.name') || 'Muu';
Expand Down Expand Up @@ -94,6 +96,7 @@ function rebuildParticipantsTable() {
email: participant.email,
internationalGuest: !!participant.localGroup,
diet: participant.diet,
accommodation: participant.accommodation,
localGroup: participant.representedParty || _.get(participant, 'localGroup.name') || 'Muu',
campGroup: _.get(participant, 'campGroup.name') || 'Muu',
subCamp: getSubCamp(participant),
Expand Down Expand Up @@ -192,6 +195,7 @@ function buildSelectionTable() {
.then(participants => Promise.each(participants, p =>
findKuksaParticipantExtraSelections({ where: { participantId: p.participantId }, include: { selection: 'group' } })
.then(participantSelections => participantSelections.map(selections => selections.toObject()))
.then(participantSelections => _.filter(participantSelections, s => !!(s.selection && s.selection.group))) // Apparently some selections don't have a group, so handle only selections with group
.then(participantSelections => _.filter(participantSelections, s => (_.indexOf(groupsToCreate, s.selection.group.name) > -1)))
.then(participantSelections => participantSelections.map(sel => ({
participantId: sel.participantId,
Expand Down

0 comments on commit c1fc1c1

Please sign in to comment.