Skip to content

Commit

Permalink
Merge pull request #1970 from bcgov/fix/dupeEndpointUpdates
Browse files Browse the repository at this point in the history
Updates to endpoints
  • Loading branch information
alexmcdermid authored Oct 17, 2024
2 parents 5fe953b + 930505c commit 51ac3c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
25 changes: 8 additions & 17 deletions backend/src/components/sdc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams, deleteData, formatNumberOfCourses, stripNumberFormattingNumberOfCourses,
const { getAccessToken, handleExceptionResponse, getData, postData, putData, getDataWithParams, formatNumberOfCourses, stripNumberFormattingNumberOfCourses,
getCreateOrUpdateUserValue} = require('./utils');
const { edxUserHasAccessToInstitute } = require('./permissionUtils');
const HttpStatus = require('http-status-codes');
Expand Down Expand Up @@ -363,23 +363,15 @@ async function updateAndValidateSdcSchoolCollectionStudent(req, res) {

}

async function deleteSDCSchoolCollectionStudent(req, res) {
try {
log.info('User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC student :: ' + req.params.sdcSchoolCollectionStudentID);
const token = getAccessToken(req);
let deletedSdcSchoolCollectionStudentData = await deleteData(token, `${config.get('sdc:schoolCollectionStudentURL')}/${req.params.sdcSchoolCollectionStudentID}`, req.session?.correlationID);
return res.status(HttpStatus.OK).json(deletedSdcSchoolCollectionStudentData);
} catch (e) {
log.error('Error deleting SDC School Collection Student.', e.stack);
return handleExceptionResponse(e, res);
}
}

async function removeSDCSchoolCollectionStudents(req, res) {
try {
log.info('EDX User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC students :: ' + JSON.stringify(req.body));
const token = getAccessToken(req);
let deletedSdcSchoolCollectionStudentData = await postData(token, req.body, `${config.get('sdc:schoolCollectionStudentURL')}/soft-delete-students`);
let payload = {
softDeleteStudentIDs: req.body,
updateUser: getCreateOrUpdateUserValue(req)
}
log.info('EDX User :: ' + getCreateOrUpdateUserValue(req) + ' is removing SDC students :: ' + JSON.stringify(payload));
let deletedSdcSchoolCollectionStudentData = await postData(token, payload, `${config.get('sdc:schoolCollectionStudentURL')}/soft-delete-students`);
return res.status(HttpStatus.OK).json(deletedSdcSchoolCollectionStudentData);
} catch (e) {
log.error('Error deleting SDC School Collection Students.', e.stack);
Expand Down Expand Up @@ -1121,7 +1113,7 @@ async function resolveDuplicates(req, res) {
student.sdcSchoolCollectionStudentEnrolledPrograms = null;
});

const data = await postData(token, payload, `${config.get('sdc:sdcDuplicateURL')}/${req.params.sdcDuplicateID}/type/${req.params.type}`, req.session?.correlationID);
const data = await postData(token, payload, `${config.get('sdc:sdcDuplicateURL')}/type/${req.params.type}`, req.session?.correlationID);
await redisUtil.unlockSdcDuplicateBeingProcessedInRedis(duplicateLock);
return res.status(HttpStatus.OK).json(data);
} catch (e) {
Expand Down Expand Up @@ -1279,7 +1271,6 @@ module.exports = {
getSDCSchoolCollectionStudentSummaryCounts,
getSDCSchoolCollectionStudentDetail,
updateAndValidateSdcSchoolCollectionStudent,
deleteSDCSchoolCollectionStudent,
markSdcSchoolCollectionStudentAsDifferent,
getStudentHeadcounts,
getSdcSchoolCollectionMonitoringBySdcDistrictCollectionId,
Expand Down
5 changes: 3 additions & 2 deletions backend/src/routes/sdc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/components/common/DuplicateTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export default defineComponent({
resolveEnrollmentDuplicateViaRemove(duplicate, sdcSchoolCollectionStudent) {
this.selectedDuplicate = duplicate;
this.selectedSdcSchoolCollectionStudent = sdcSchoolCollectionStudent;
this.$refs.resolveEnrollmentDuplicateViaRemoveStudent.removeAndResolveStudent(duplicate, sdcSchoolCollectionStudent);
this.$refs.resolveEnrollmentDuplicateViaRemoveStudent.removeAndResolveStudent(sdcSchoolCollectionStudent);
},
closeAndRefreshDuplicates() {
this.openProgramResolutionView = false;
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/common/EditStudent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,10 @@ export default {
}
this.loadingCount += 1;
this.hasError = false;
ApiService.apiAxios.delete(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.selectedSdcStudentID}`, this.sdcSchoolCollectionStudentDetailCopy)
let studentToRemove = [];
studentToRemove.push(this.selectedSdcStudentID);

ApiService.apiAxios.post(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.sdcSchoolCollectionStudentDetailCopy.sdcSchoolCollectionID}/students/remove`, studentToRemove)
.then(() => {
this.removeIndex = this.selectedStudents.findIndex(value => value === this.selectedSdcStudentID);
this.selectedStudents.splice(this.removeIndex, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ export default {
},
methods: {
displayName,
async removeAndResolveStudent(duplicate, sdcSchoolCollectionStudent) {
async removeAndResolveStudent(sdcSchoolCollectionStudent) {
this.sdcSchoolCollectionStudent = sdcSchoolCollectionStudent;
let studentToRemove = [];
studentToRemove.push(this.sdcSchoolCollectionStudent.sdcSchoolCollectionStudentID);
const confirmation = await this.$refs.confirmResolveEnrollmentDuplicateViaRemoveStudent.open('Remove Student', null, {color: '#fff', width: 580, closeIcon: false, subtitle: false, dark: false, resolveText: 'Remove', rejectText: 'Cancel'});
if (!confirmation) {
return;
}
let payload = {
students: [this.sdcSchoolCollectionStudent],
duplicate: duplicate
};
ApiService.apiAxios.post(ApiRoutes.sdc.SDC_DUPLICATE_RESOLVE + '/'+ duplicate?.sdcDuplicateID + '/DELETE_ENROLLMENT_DUPLICATE', payload)
ApiService.apiAxios.post(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.sdcSchoolCollectionStudent.sdcSchoolCollectionID}/students/remove`, studentToRemove)
.then(() => {
setSuccessAlert('Success! The student has been removed.');
}).catch(error => {
Expand Down

0 comments on commit 51ac3c9

Please sign in to comment.