Add receiving college review to approvals

This commit is contained in:
biss committed 2026-12-01 10:17:26 +08:00
1 parent 784b5b76f2
commit 3ce77d9cd9
3 files changed
+27 -3

No files matched your search

@@ -959,11 +959,25 @@ public sealed class ApprovalsController(
AddCount("CourseSubstitution", await substitutions.WhereApprovalBefore(x => x.SubmittedAt, cutoff).CountAsync(ct));
var canCollegeReview = scope.Current.IsInRole(SystemRoles.CollegeAdmin);
items.AddRange(await Scoped<StudentStatusChange>(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved))
var statusChanges = Scoped<StudentStatusChange>(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved && (x.Type != StudentStatusChangeType.MajorTransfer || x.OriginalClass == null || x.TargetClass == null || x.OriginalClass.Major!.CollegeId == x.TargetClass.Major!.CollegeId || (x.ReceivingCollegeReviewedAt != null && x.ReceivingCollegeId == x.TargetClass.Major!.CollegeId))));
items.AddRange(await statusChanges
.WhereApprovalBefore(x => x.SubmittedAt, cutoff).OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, x.State == StudentStatusChangeState.CounselorApproved ? "college" : "final"))
.ToListAsync(ct));
AddCount("StudentStatusChange", await Scoped<StudentStatusChange>(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved)).WhereApprovalBefore(x => x.SubmittedAt, cutoff).CountAsync(ct));
AddCount("StudentStatusChange", await statusChanges.WhereApprovalBefore(x => x.SubmittedAt, cutoff).CountAsync(ct));
if (canCollegeReview)
{
var receiving = db.StudentStatusChanges.AsNoTracking().Where(x => x.Type == StudentStatusChangeType.MajorTransfer && x.State == StudentStatusChangeState.CollegeApproved && x.ReceivingCollegeReviewedAt == null && x.OriginalClass != null && x.TargetClass != null && x.OriginalClass.Major!.CollegeId != x.TargetClass.Major!.CollegeId);
if (current.Scope != DataScope.All)
{
var receivingCollegeId = current.RestrictedCollegeId;
receiving = current.Scope == DataScope.College && receivingCollegeId.HasValue ? receiving.Where(x => x.TargetClass!.Major!.CollegeId == receivingCollegeId) : receiving.Where(x => false);
}
items.AddRange(await receiving.WhereApprovalBefore(x => x.SubmittedAt, cutoff).OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — 转入 {x.TargetClass!.Major!.Name} / {x.TargetClass.Name}", x.Reason, x.SubmittedAt, x.TargetClass.Major.College!.Name, "receivingCollege")).ToListAsync(ct));
AddCount("StudentStatusChange", await receiving.WhereApprovalBefore(x => x.SubmittedAt, cutoff).CountAsync(ct));
}
items.AddRange(await Scoped<CourseAdjustment>(x => x.Status == CourseAdjustmentStatus.Submitted)
.WhereApprovalBefore(x => x.SubmittedAt ?? x.CreatedAt, cutoff).OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
@@ -1395,9 +1395,18 @@ public sealed class ApprovalsControllerTests
var page = Assert.IsType<StudentStatusChangePage>(Assert.IsType<OkObjectResult>(pageResponse.Result).Value);
Assert.Single(page.Items);
Assert.Equal(1, page.ActionableTotal);
var receivingPending = await new ApprovalsController(fixture.Db, new CollegeDataScope(college.Id)).GetPending(1, 20, CancellationToken.None, type: "StudentStatusChange");
var receivingPage = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(receivingPending.Result).Value);
Assert.Equal("receivingCollege", Assert.Single(receivingPage.Items).Stage);
var finalPending = await new ApprovalsController(fixture.Db, new ManagerDataScope()).GetPending(1, 20, CancellationToken.None, type: "StudentStatusChange");
Assert.Empty(Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(finalPending.Result).Value).Items);
var wrongCollegePending = await new ApprovalsController(fixture.Db, new CollegeDataScope(fixture.CurrentCourse.CollegeId)).GetPending(1, 20, CancellationToken.None, type: "StudentStatusChange");
Assert.Empty(Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(wrongCollegePending.Result).Value).Items);
Assert.IsType<ForbidResult>(await originalCollege.ReviewReceivingCollege(change.Id, new StudentStatusReviewRequest(true, null), CancellationToken.None));
Assert.IsType<ConflictObjectResult>(await reviewer.Review(change.Id, new StudentStatusReviewRequest(true, null), CancellationToken.None));
Assert.IsType<NoContentResult>(await receivingCollege.ReviewReceivingCollege(change.Id, new StudentStatusReviewRequest(true, "同意接收"), CancellationToken.None));
finalPending = await new ApprovalsController(fixture.Db, new ManagerDataScope()).GetPending(1, 20, CancellationToken.None, type: "StudentStatusChange");
Assert.Equal("final", Assert.Single(Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(finalPending.Result).Value).Items).Stage);
Assert.IsType<NoContentResult>(await reviewer.Review(change.Id, new StudentStatusReviewRequest(true, null), CancellationToken.None));
Assert.Equal(target.Id, (await fixture.Db.Students.FindAsync(fixture.Student.Id))!.AdministrativeClassId);
Assert.Equal(college.Id, (await fixture.Db.StudentStatusChanges.SingleAsync()).ReceivingCollegeId);
+2 -1
View File
@@ -651,7 +651,7 @@ async function rejectSubmit() {
async function submitReview(item: any, approved: boolean, comment: string) {
if (item.type === "StudentStatusChange")
await http.post(`/student-status-changes/${item.id}/review`, {
await http.post(`/student-status-changes/${item.id}/${item.stage === 'receivingCollege' ? 'receiving-college-review' : 'review'}`, {
approved,
comment: comment || null,
});
@@ -775,6 +775,7 @@ function updateOverdueHours(value: number | undefined) {
}
function approvalStageLabel(stage: string) {
if (stage === "receivingCollege") return attachmentText("转入学院审核", "Receiving college review");
if (stage === "counselor") return t("approvalCenterCounselorStage");
if (stage === "dormitory") return t("approvalCenterDormitoryStage");
return stage === "college"