-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix Failing Course Deletion if Approved/Rejected Enrol Requests Exist #7642
base: master
Are you sure you want to change the base?
Conversation
@@ -24,6 +24,7 @@ def create | |||
# Allow users to withdraw their requests to register for a course that are pending | |||
# approval/rejection. | |||
def destroy | |||
@enrol_request.is_validation_for_destroy_required = true |
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.
Since course deletion will bypass controller and go straight to model, why not move the workflow_state == 'pending'
check to the controller instead?
Then we can save on an additional is_validation_for_destroy_required
attribute which is only set in the controller destroy anyway.
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.
as discussed, we decided to move the validation logic for deletion to the controller instead of model, since the validation will only be called while destroying object through controller
a60bc37
to
4a68336
Compare
4a68336
to
4395490
Compare
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.
LGTM
Background
Previously, having at least one Approved/Rejected enrol requests inside the course will give an error if one wants to delete the course
Root Causes
Based on this PR #4212, we wants to keep track on the enrol requests that are approved/rejected, and hence we disallow the requester to retract their enrol requests if theirs have been approved / rejected (not pending) by adding validation rules before destroying the enrol requests. However, this same validation will also takes place when we delete course, since
enrol_request
is the child ofcourse
and henceenrol_request
will be subsequently deleted due to cascading.Approach
We moved the validation for destroy towards
enrol_request_controller
, since we noticed that the validation will only be accessed should we send the request through controller and not through parent deletion