Skip to content

Conversation

@RosaGao
Copy link
Collaborator

@RosaGao RosaGao commented Apr 22, 2023

Added PATCH /api/courses/:course_id which takes in a course id as param and a new course as req body for deleting the old course and adding the new course

@RosaGao RosaGao requested a review from mpark63 April 22, 2023 02:36
@render
Copy link

render bot commented Apr 22, 2023

Copy link
Collaborator

@mpark63 mpark63 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gj rosa! requested some changes, lmk what you think!
Also, please making a corresponding PR in frontend that uses this new route.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be in the PR? :?
For clean files changed history, please make a fresh branch from dev and add your update course changes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, this file hsould not be in the PR

routes/course.js Outdated
Comment on lines 290 to 299
for (let id of course.distribution_ids) {
const distribution = await Distributions
.findByIdAndUpdate(
id,
{ $pull: { courses: c_id } },
{ new: true, runValidators: true }
)
.exec();
await distributionCreditUpdate(distribution, course, false);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this code, as Distributions are unused at this point in time

routes/course.js Outdated
Comment on lines 323 to 329
for (const existingCourse of retrievedCourses) {
if(existingCourse.number === course.number && existingCourse.term === course.term && existingCourse.year === course.year && existingCourse.title === course.title){
return errorHandler(res, 400, {
message: "Cannot take same course multiple times in the same semester",
});
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would not be necessary as hopefully there were no duplicate courses to begin with.
but maybe that's not a correct assumption.

I'll leave it up to you!

routes/course.js Outdated
Comment on lines 316 to 321
course.distribution_ids.forEach((id) => {
if (!plan.distribution_ids.includes(id))
errorHandler(res, 500, {
message: "Invalid combination of plan_id and distribution_ids.",
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need




describe("Course Routes: PATCH /api/courses/:course_id", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice tests!

@RosaGao RosaGao requested a review from mpark63 May 14, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants