Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bcgov/EDUC-STUDENT-ADMIN
Browse files Browse the repository at this point in the history
…into fix/edx-1873
  • Loading branch information
eckermania committed Oct 18, 2023
2 parents 71ca122 + 40c1077 commit 22f1049
Show file tree
Hide file tree
Showing 46 changed files with 3,077 additions and 2,694 deletions.
19 changes: 9 additions & 10 deletions backend/src/components/edx/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ async function getExchanges(req, res) {
element['contactIdentifierName'] = tempMinTeam.teamName;
}
}
if (element['createDate']) {
element['createDate'] = LocalDateTime.parse(element['createDate']).format(DateTimeFormatter.ofPattern('uuuu/MM/dd'));
}
});
}
return res.status(200).json(dataResponse);
Expand Down Expand Up @@ -190,10 +187,6 @@ async function getExchange(req, res) {
dataResponse['districtName'] = district.name;
}

if (dataResponse['createDate']) {
dataResponse['createDate'] = LocalDateTime.parse(dataResponse['createDate']).format(DateTimeFormatter.ofPattern('uuuu/MM/dd'));
}

//creating activities list for timeline display on the frontend
dataResponse['activities'] = [];
dataResponse['commentsList'].forEach((comment) => {
Expand Down Expand Up @@ -510,7 +503,8 @@ async function districtUserActivationInvite(req, res) {
}

const payload = {
...req.body
...req.body,
edxUserExpiryDate: req.body.edxUserExpiryDate
};
try {
const response = await utils.postData(token, config.get('server:edx:districtUserActivationInviteURL'), payload, null, utils.getUser(req).idir_username);
Expand All @@ -536,7 +530,8 @@ async function schoolUserActivationInvite(req, res) {
}

const payload = {
...req.body
...req.body,
edxUserExpiryDate: req.body.edxUserExpiryDate
};
try {
const response = await utils.postData(token, config.get('server:edx:schoolUserActivationInviteURL'), payload, null, utils.getUser(req).idir_username);
Expand Down Expand Up @@ -580,6 +575,7 @@ async function updateEdxUserSchoolRoles(req, res) {

selectedUserSchool.updateDate = null;
selectedUserSchool.createDate = null;
selectedUserSchool.expiryDate = req.body.params.expiryDate;

const result = await utils.putData(token, `${config.get('server:edx:edxUsersURL')}/${selectedUserSchool.edxUserID}/school`, selectedUserSchool, userInfo.idir_username);
return res.status(HttpStatus.OK).json(result);
Expand Down Expand Up @@ -621,6 +617,7 @@ async function updateEdxUserDistrictRoles(req, res) {

selectedUserDistrict.updateDate = null;
selectedUserDistrict.createDate = null;
selectedUserDistrict.expiryDate = req.body.params.expiryDate;

const result = await utils.putData(token, `${config.get('server:edx:edxUsersURL')}/${selectedUserDistrict.edxUserID}/district`, selectedUserDistrict, userInfo.idir_username);
return res.status(HttpStatus.OK).json(result);
Expand Down Expand Up @@ -709,7 +706,7 @@ const createSearchParamObject = (key, value) => {
valueType = VALUE_TYPE.UUID;
} else if (key === 'createDate') {
value.forEach((date, index) => {
value[index] = date + 'T00:00:00';
value[index] = date;
});
if (value.length === 1) {
value.push(LocalDateTime.parse(value[0]).plusHours(23).plusMinutes(59).plusSeconds(59));
Expand Down Expand Up @@ -856,6 +853,7 @@ async function relinkUserSchoolOrDistrictAccess(req, res) {
email: edxUserDetails.email,
edxUserId: req.body.params.userToRelink,
edxUserSchoolID: req.body.params.userSchoolID,
edxUserExpiryDate: req.body.params.edxUserExpiryDate
};
await postData(token, config.get('server:edx:exchangeURL') + '/school-user-activation-relink-saga', payload,null, userName);
} else {
Expand All @@ -870,6 +868,7 @@ async function relinkUserSchoolOrDistrictAccess(req, res) {
email: edxUserDetails.email,
edxUserId: req.body.params.userToRelink,
edxUserDistrictID: req.body.params.edxUserDistrictID,
edxUserExpiryDate: req.body.params.edxUserExpiryDate
};
await postData(token, config.get('server:edx:exchangeURL') + '/district-user-activation-relink-saga', payload,null, userName);
}
Expand Down
48 changes: 16 additions & 32 deletions backend/src/components/institute/institute.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async function getDistricts(req, res) {
async function addDistrictContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let district = cacheService.getDistrictJSONByDistrictId(req.body.districtID);
if(!district || !hasDistrictAdminRole(req)){
Expand All @@ -85,8 +84,8 @@ async function addDistrictContact(req, res) {
phoneExtension: req.body.phoneExtension,
alternatePhoneNumber: req.body.alternatePhoneNumber,
alternatePhoneExtension: req.body.alternatePhoneExtension,
effectiveDate: req.body.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null,
expiryDate: req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null
effectiveDate: req.body.effectiveDate ? req.body.effectiveDate : null,
expiryDate: req.body.expiryDate ? req.body.expiryDate : null
};

const data = await utils.postData(token, url, payload, null, utils.getUser(req).idir_username);
Expand Down Expand Up @@ -166,7 +165,6 @@ async function updateDistrict(req, res) {
async function updateDistrictContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let district = cacheService.getDistrictJSONByDistrictId(req.body.districtId);
if(!district || !hasDistrictAdminRole(req)){
Expand All @@ -185,8 +183,6 @@ async function updateDistrictContact(req, res) {
params.updateDate = null;
params.createDate = null;
params.updateUser = utils.getUser(req).idir_username;
params.effectiveDate = params.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null;
params.expiryDate = req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null;

const result = await utils.putData(token, `${config.get('server:institute:instituteDistrictURL')}/${req.body.districtId}/contact/${req.params.contactId}` , params, utils.getUser(req).idir_username);
return res.status(HttpStatus.OK).json(result);
Expand All @@ -199,7 +195,6 @@ async function updateDistrictContact(req, res) {
async function deleteDistrictContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let district = cacheService.getDistrictJSONByDistrictId(req.params.districtId);
if(!district || !hasDistrictAdminRole(req)){
Expand All @@ -225,7 +220,7 @@ async function deleteDistrictContact(req, res) {
contact.createDate = null;
contact.updateDate = null;
contact.updateUser = utils.getUser(req).idir_username;
contact.expiryDate = LocalDateTime.now().format(formatter);
contact.expiryDate = LocalDate.now().atStartOfDay().format(DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss'));

await utils.putData(token, config.get('server:institute:instituteDistrictURL') + '/' + req.params.districtId + '/contact/'+ req.params.contactId , contact, utils.getUser(req).idir_username);

Expand Down Expand Up @@ -347,8 +342,6 @@ async function addSchool(req, res) {
});
}

const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

const payload = {
createUser: utils.getUser(req).idir_username,
createDate: null,
Expand All @@ -366,7 +359,7 @@ async function addSchool(req, res) {
schoolOrganizationCode: req.body.schoolOrganizationCode,
schoolCategoryCode: req.body.schoolCategoryCode,
facilityTypeCode: req.body.facilityTypeCode,
openedDate: req.body.openedDate ? LocalDate.parse(req.body.openedDate).atStartOfDay().format(formatter) : null,
openedDate: req.body.openedDate ? req.body.openedDate : null,
closedDate: null,
addresses: [],
grades: [],
Expand Down Expand Up @@ -496,7 +489,6 @@ async function deleteSchoolNote(req, res) {
async function addSchoolContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let school = cacheService.getSchoolBySchoolID(req.body.schoolID);
if(!school || !hasSchoolAdminRole(req, school)){
Expand All @@ -523,8 +515,8 @@ async function addSchoolContact(req, res) {
phoneExtension: req.body.phoneExtension,
alternatePhoneNumber: req.body.alternatePhoneNumber,
alternatePhoneExtension: req.body.alternatePhoneExtension,
effectiveDate: req.body.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null,
expiryDate: req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null
effectiveDate: req.body.effectiveDate ? req.body.effectiveDate : null,
expiryDate: req.body.expiryDate ? req.body.expiryDate : null
};

const data = await utils.postData(token, url, payload, null, utils.getUser(req).idir_username);
Expand All @@ -539,7 +531,6 @@ async function addSchoolContact(req, res) {
async function updateSchoolContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let school = cacheService.getSchoolBySchoolID(req.body.schoolID);
if(!school || !hasSchoolAdminRole(req, school)){
Expand All @@ -558,8 +549,9 @@ async function updateSchoolContact(req, res) {
params.updateDate = null;
params.createDate = null;
params.updateUser = utils.getUser(req).idir_username;
params.effectiveDate = params.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null;
params.expiryDate = req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null;
params.effectiveDate = params.effectiveDate ? req.body.effectiveDate : null;
params.expiryDate = req.body.expiryDate ? req.body.expiryDate : null;
params.expiryDate = req.body.expiryDate ? req.body.expiryDate : null;

const result = await utils.putData(token, config.get('server:institute:instituteSchoolURL') + '/' + req.body.schoolID + '/contact/'+ req.params.contactId , params, utils.getUser(req).idir_username);
return res.status(HttpStatus.OK).json(result);
Expand All @@ -572,7 +564,6 @@ async function updateSchoolContact(req, res) {
async function deleteSchoolContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let school = cacheService.getSchoolBySchoolID(req.params.schoolId);
if(!school || !hasSchoolAdminRole(req, school)){
Expand All @@ -598,7 +589,7 @@ async function deleteSchoolContact(req, res) {
contact.createDate = null;
contact.updateDate = null;
contact.updateUser = utils.getUser(req).idir_username;
contact.expiryDate = LocalDateTime.now().format(formatter);
contact.expiryDate = LocalDate.now().atStartOfDay().format(DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss'));

await utils.putData(token, config.get('server:institute:instituteSchoolURL') + '/' + req.params.schoolId + '/contact/'+ req.params.contactId , contact, utils.getUser(req).idir_username);

Expand All @@ -612,7 +603,6 @@ async function deleteSchoolContact(req, res) {
async function addAuthorityContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let authority = cacheService.getAuthorityJSONByAuthorityId(req.body.authorityID);
if(!authority || !hasAuthorityAdminRole(req, authority)){
Expand All @@ -639,8 +629,8 @@ async function addAuthorityContact(req, res) {
phoneExtension: req.body.phoneExtension,
alternatePhoneNumber: req.body.alternatePhoneNumber,
alternatePhoneExtension: req.body.alternatePhoneExtension,
effectiveDate: req.body.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null,
expiryDate: req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null
effectiveDate: req.body.effectiveDate ? req.body.effectiveDate : null,
expiryDate: req.body.expiryDate ? req.body.expiryDate : null
};

const data = await utils.postData(token, url, payload, null, utils.getUser(req).idir_username);
Expand All @@ -655,7 +645,6 @@ async function addAuthorityContact(req, res) {
async function updateAuthorityContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let authority = cacheService.getAuthorityJSONByAuthorityId(req.body.independentAuthorityId);
if(!authority || !hasAuthorityAdminRole(req, authority)){
Expand All @@ -674,8 +663,6 @@ async function updateAuthorityContact(req, res) {
params.updateDate = null;
params.createDate = null;
params.updateUser = utils.getUser(req).idir_username;
params.effectiveDate = params.effectiveDate ? LocalDate.parse(req.body.effectiveDate).atStartOfDay().format(formatter) : null;
params.expiryDate = req.body.expiryDate ? LocalDate.parse(req.body.expiryDate).atStartOfDay().format(formatter) : null;

const result = await utils.putData(token, config.get('server:institute:instituteAuthorityURL') + '/' + req.body.independentAuthorityId + '/contact/'+ req.params.contactId , params, utils.getUser(req).idir_username);
return res.status(HttpStatus.OK).json(result);
Expand All @@ -688,7 +675,6 @@ async function updateAuthorityContact(req, res) {
async function deleteAuthorityContact(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

let authority = cacheService.getAuthorityJSONByAuthorityId(req.params.independentAuthorityId);
if(!authority || !hasAuthorityAdminRole(req, authority)){
Expand All @@ -714,7 +700,7 @@ async function deleteAuthorityContact(req, res) {
contact.createDate = null;
contact.updateDate = null;
contact.updateUser = utils.getUser(req).idir_username;
contact.expiryDate = LocalDateTime.now().format(formatter);
contact.expiryDate = LocalDate.now().atStartOfDay().format(DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss'));

await utils.putData(token, config.get('server:institute:instituteAuthorityURL') + '/' + req.params.independentAuthorityId + '/contact/'+ req.params.contactId , contact, utils.getUser(req).idir_username);

Expand All @@ -728,7 +714,6 @@ async function deleteAuthorityContact(req, res) {
async function addAuthority(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

if(!hasAuthorityAdminRole(req)){
return res.status(HttpStatus.UNAUTHORIZED).json({
Expand All @@ -742,7 +727,7 @@ async function addAuthority(req, res) {

displayName: req.body.authorityName,
authorityTypeCode: req.body.authorityTypeCode,
openedDate: req.body.openDate ? LocalDate.parse(req.body.openDate).atStartOfDay().format(formatter) : null,
openedDate: req.body.openDate ? req.body.openDate : null,
email: req.body.email,
phoneNumber: req.body.phoneNumber,
faxNumber: req.body.faxNumber,
Expand Down Expand Up @@ -991,7 +976,6 @@ async function getSchoolsPaginated(req, res){
async function moveSchool(req, res) {
try {
const token = getBackendToken(req);
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ss');

if(!hasSchoolAdminRole(req, req.body.toSchool)){
return res.status(HttpStatus.UNAUTHORIZED).json({
Expand All @@ -1000,7 +984,7 @@ async function moveSchool(req, res) {
}

const incomingPayload = req.body;
incomingPayload.toSchool.openedDate = LocalDate.parse(incomingPayload.toSchool.moveDate).atStartOfDay().format(formatter);
incomingPayload.toSchool.openedDate = incomingPayload.toSchool.moveDate;
incomingPayload.toSchool.createDate = null;
incomingPayload.toSchool.updateDate = null;
incomingPayload.toSchool.createUser = utils.getUser(req).idir_username;
Expand Down Expand Up @@ -1055,7 +1039,7 @@ async function moveSchool(req, res) {

const payload = {
toSchool: incomingPayload.toSchool,
moveDate: LocalDate.parse(incomingPayload.toSchool.moveDate).atStartOfDay().format(formatter),
moveDate: incomingPayload.toSchool.moveDate,
fromSchoolId: req.body.fromSchoolId
};

Expand Down
3 changes: 2 additions & 1 deletion backend/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ nconf.defaults({
frontendConfig: {
bannerEnvironment: process.env.BANNER_ENVIRONMENT,
bannerColor: process.env.BANNER_COLOR,
webSocketURL: process.env.WEB_SOCKET_URL
webSocketURL: process.env.WEB_SOCKET_URL,
disableSdcFunctionality: process.env.DISABLE_SDC_FUNCTIONALITY === 'true'
},
sdc: {
rootURL: process.env.SDC_API_URL,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ async function getConfig(req, res) {
const frontConfig = {
BANNER_ENVIRONMENT: frontendConfig.bannerEnvironment,
BANNER_COLOR: frontendConfig.bannerColor,
WEB_SOCKET_URL: frontendConfig.webSocketURL
WEB_SOCKET_URL: frontendConfig.webSocketURL,
DISABLE_SDC_FUNCTIONALITY: frontendConfig.disableSdcFunctionality
};
return res.status(HttpStatus.OK).json(frontConfig);
}
Expand Down
12 changes: 7 additions & 5 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ cacheService.loadDataToCache( constants.CACHE_KEYS.AUTHORITY_CONTACT_TYPES, 'ser
}).catch((e) => {
log.error('Error loading AUTHORITY_CONTACT_TYPES data during boot .', e);
});
cacheService.loadDataToCache( constants.CACHE_KEYS.SDC_FUNDING_GROUPS, 'sdc:fundingGroupsURL').then(() => {
log.info('Loaded FUNDING_GROUPS data to memory');
}).catch((e) => {
log.error('Error loading FUNDING_GROUPS data during boot .', e);
});
if(!config.get('frontendConfig').disableSdcFunctionality) {
cacheService.loadDataToCache( constants.CACHE_KEYS.SDC_FUNDING_GROUPS, 'sdc:fundingGroupsURL').then(() => {
log.info('Loaded FUNDING_GROUPS data to memory');
}).catch((e) => {
log.error('Error loading FUNDING_GROUPS data during boot .', e);
});
}

cacheService.loadAllAuthoritiesToMap().then(() => {
log.info('Loaded authorities data to memory');
Expand Down
Loading

0 comments on commit 22f1049

Please sign in to comment.