From e886d7dc12c55187b3ceacee581a687bc39fa88f Mon Sep 17 00:00:00 2001 From: Marco Villeneuve Date: Mon, 13 May 2024 17:15:52 -0700 Subject: [PATCH] Small fix --- backend/src/components/edx/exchange.js | 5 +++-- backend/src/components/institute/institute.js | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/src/components/edx/exchange.js b/backend/src/components/edx/exchange.js index 4df340e95..3819beff0 100644 --- a/backend/src/components/edx/exchange.js +++ b/backend/src/components/edx/exchange.js @@ -9,6 +9,7 @@ const {FILTER_OPERATION, VALUE_TYPE, CACHE_KEYS} = require('../../util/constants const {LocalDateTime, DateTimeFormatter} = require('@js-joda/core'); const cacheService = require('../cache-service'); const log = require('../logger'); +const {setIssueTranscriptAndCertificatesFlags} = require('../institute/institute'); async function claimAllExchanges(req, res) { try { @@ -995,6 +996,7 @@ async function createSchool(req, res) { }); } + await setIssueTranscriptAndCertificatesFlags(school); const userInfo = utils.getUser(req); const payload = { school: { @@ -1064,13 +1066,12 @@ async function findAllSchoolInvitations(req, res) { async function uploadOnboardingFile(req, res){ try { - console.log("Upload file: ", JSON.stringify(req.body)) const user = utils.getUser(req); const document = { fileContents: req.body.fileContents, createUser: user.idir_username - } + }; const result = await postData(config.get('server:edx:uploadOnboardingFile'), document, null, null); return res.status(HttpStatus.OK).json(result); diff --git a/backend/src/components/institute/institute.js b/backend/src/components/institute/institute.js index 5bf03a5b8..3d6064d39 100644 --- a/backend/src/components/institute/institute.js +++ b/backend/src/components/institute/institute.js @@ -395,6 +395,8 @@ async function addSchool(req, res) { payload.grades = req.body.grades; } + await setIssueTranscriptAndCertificatesFlags(payload); + const data = await utils.postData(config.get('server:institute:instituteSchoolURL'), payload, null, utils.getUser(req).idir_username); return res.status(HttpStatus.OK).json(data); } catch (e) { @@ -1358,9 +1360,9 @@ async function setIssueTranscriptAndCertificatesFlags(school){ let canIssueTranscripts = false; let canIssueCertificates = false; - let grade10toSUFundingCodes = school.schoolFundingGroups.filter(group => gradesArray.includes(group.schoolGradeCode)); - let schoolHas10toSUGrades = school.grades.some(grade => gradesArray.includes(grade.schoolGradeCode)); - let hasGroup1or2or4 = grade10toSUFundingCodes.some(group => groupsArray.includes(group.schoolFundingGroupCode)); + let grade10toSUFundingCodes = school.schoolFundingGroups?.filter(group => gradesArray.includes(group.schoolGradeCode)); + let schoolHas10toSUGrades = school.grades?.some(grade => gradesArray.includes(grade.schoolGradeCode)); + let hasGroup1or2or4 = grade10toSUFundingCodes?.some(group => groupsArray.includes(group.schoolFundingGroupCode)); switch(school.schoolCategoryCode) { case 'PUBLIC': @@ -1467,6 +1469,7 @@ module.exports = { updateFundingDataForSchool, getFundingGroupDataForSchool, moveSchool, + setIssueTranscriptAndCertificatesFlags, getStudentRegistrationContacts, getStudentRegistrationContactByMincode, getSchoolByMincode,