#5106 - Institution restriction institution impacts - Create offering API validations#5634
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements validation to prevent creating or updating education program offerings when institution restrictions are in place. The core change is the addition of a custom validator IsActionAllowed that checks if offering actions (create, update, request change, validate) are blocked by effective restriction actions, specifically the StopOfferingCreate restriction type.
Changes:
- Added a custom validator
IsActionAllowedto check if offering actions are allowed based on effective restriction actions - Extended the
OfferingValidationModelto includeeffectiveRestrictionActionsandactionTypefields - Updated offering creation, update, and validation flows to retrieve and validate against institution restrictions
- Added comprehensive E2E tests for create, update, and bulk insert scenarios with restrictions
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
education-program-offering-validation.models.ts |
Added OfferingActionType enum, effectiveRestrictionActions and actionType properties to OfferingValidationModel, and return type annotations to helper functions |
is-action-allowed.ts |
New custom validator that checks if offering actions are blocked by restriction actions, with specific error messaging for create operations |
education-program-offering-import-csv.service.ts |
Updated CSV import to fetch institution restrictions and populate effectiveRestrictionActions and actionType for bulk offering validation |
education-program-offering.controller.service.ts |
Modified buildOfferingValidationModel to accept actionType parameter and retrieve effective restrictions for location and program combinations |
education-program-offering.institutions.controller.ts |
Updated all offering endpoints (validate, create, update, request change) to pass appropriate OfferingActionType to the validation model builder |
education-program-offering.institutions.controller.createOffering.e2e-spec.ts |
Added E2E test verifying that creating an offering is blocked when StopOfferingCreate restriction is active |
education-program-offering.institutions.controller.updateProgramOffering.e2e-spec.ts |
Added E2E test confirming that updating an offering is allowed even when StopOfferingCreate restriction is active (only blocks creation) |
education-program-offering.institutions.controller.bulkInsert.e2e-spec.ts |
Added E2E test for bulk offering validation with restrictions, plus refactored setup to improve test isolation |
| }) | ||
| institutionContext?: InstitutionValidationContext; | ||
| /** | ||
| * Effective restriction actions for the local and program. |
There was a problem hiding this comment.
The JSDoc comment has a typo: "local" should be "location".
| * Effective restriction actions for the local and program. | |
| * Effective restriction actions for the location and program. |
.../api/src/services/education-program-offering/custom-validators/is-offering-action-allowed.ts
Show resolved
Hide resolved
| const blockingRestrictionActionMap = new Map([ | ||
| [OfferingActionType.Create, RestrictionActionType.StopOfferingCreate], | ||
| ]); |
There was a problem hiding this comment.
The map can be a const outside the method.
There was a problem hiding this comment.
I was going back and forth between keeping the map outside the method or within the constraint, but I do not see any benefit of keeping the map outside and passing it to the decorator. Let me know if there are any benefits keeping the map outside
There was a problem hiding this comment.
For consistency's sake, I think that constant Arrays/Sets/Maps should follow constant naming conventions and defined at file level. That being see, I realize that this Map won't be used outside of this method.
...api/src/services/education-program-offering/education-program-offering-import-csv.service.ts
Show resolved
Hide resolved
...api/src/services/education-program-offering/education-program-offering-import-csv.service.ts
Show resolved
Hide resolved
...api/src/services/education-program-offering/education-program-offering-import-csv.service.ts
Outdated
Show resolved
Hide resolved
...oute-controllers/education-program-offering/education-program-offering.controller.service.ts
Show resolved
Hide resolved
.../api/src/services/education-program-offering/education-program-offering-validation.models.ts
Outdated
Show resolved
Hide resolved
.../api/src/services/education-program-offering/education-program-offering-validation.models.ts
Outdated
Show resolved
Hide resolved
andrewsignori-aot
left a comment
There was a problem hiding this comment.
Great work, please take a look at the comments.
...ng/_tests_/e2e/education-program-offering.institutions.controller.createOffering.e2e-spec.ts
Outdated
Show resolved
Hide resolved
andrewsignori-aot
left a comment
There was a problem hiding this comment.
Thanks for making the changes, looks good 👍
|




Institution restriction institution impacts - Create offering API validations
Offering validation
Offering validation modalIsActionAllowedto validate if the action is allowed. As of now restriction action is the only blocking factor to stop an action.E2E tests
Stop create offeringis present.Stop create offeringis present.