-
Notifications
You must be signed in to change notification settings - Fork 3
Dev 147: Update course should be its own route #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Your Render PR Server URL is https://ucredit-dev-pr-90.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-ch1kgfhmbg57g9rj1bbg. |
mpark63
left a comment
There was a problem hiding this 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| 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); | ||
| } |
There was a problem hiding this comment.
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
| 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", | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
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
| course.distribution_ids.forEach((id) => { | ||
| if (!plan.distribution_ids.includes(id)) | ||
| errorHandler(res, 500, { | ||
| message: "Invalid combination of plan_id and distribution_ids.", | ||
| }); | ||
| }); |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice tests!
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