Repository navigation
feat: add new cycle form to admin cycles page (#802) - #822
wilsonadenuga wants to merge 5 commits into
Conversation
Allow authorized admins to create mentorship cycles in draft status with date validation, default mentee capacity, and duplicate-cycle conflict handling. Add request validation and unit/integration coverage for successful creation, invalid values, authorization, and conflicts.
Create the mentorship cycle request before the assertion so the exception-testing lambda contains only the service invocation.
Add Year and Month types with future-date validation for mentorship cycle creation, restrict new cycles to February through November, and return a readable error for invalid month values. Add matching entity validation, a Flyway database constraint, and update affected tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| && Month.class.equals(invalidFormat.getTargetType()) | ||
| && invalidFormat.getPath().stream() | ||
| .anyMatch(reference -> "cycleMonth".equals(reference.getFieldName()))) { | ||
| return "Cycle month must be between February and November"; |
There was a problem hiding this comment.
Please remove this, new validator should handle it automatically.
There was a problem hiding this comment.
Hello, this PR builds on #804. For backend changes, comment there so the PR owner can work on them. @goelsonali
| @@ -0,0 +1,6 @@ | |||
| -- Restrict new mentorship cycles to February through November. | |||
| -- Existing January and December cycles remain valid historical data. | |||
| ALTER TABLE mentorship_cycles | |||
There was a problem hiding this comment.
This is not required at all, as the validation in frontend and backend will stop any creation of new cycle. Database check is not required and is incorrect.
There was a problem hiding this comment.
Hello, this PR builds on #804. For backend changes, comment there so the PR owner can work on them. @goelsonali
| .cycleEndDate(request.cycleEndDate()) | ||
| .status(CycleStatus.DRAFT) | ||
| .maxMenteesPerMentor( | ||
| request.maxMenteesPerMentor() != null ? request.maxMenteesPerMentor() : 5) |
There was a problem hiding this comment.
The annotation should take care of validation, not required to do the check again.
- @min(1)
private Integer maxMenteesPerMentor;
There was a problem hiding this comment.
Hello, this PR builds on #804. For backend changes, comment there so the PR owner can work on them. @goelsonali



Depends on #804 (the create cycle endpoint). Until it's merged, this diff also shows #804's changes.
Description
Adds a New cycle form to the Cycles page.
Related Issue
Closes #802
Change Type
Screenshots
New cycle form
Date validation (cycle start must be after registration end)
Cycle created: success alert and the new row highlighted
Duplicate cycle: API error shown in the form
Pull request checklist
Please check if your PR fulfills the following requirements: