From a9be7649ccf82a6b7ce33882a1269f586532b517 Mon Sep 17 00:00:00 2001 From: alison11liu Date: Mon, 5 Oct 2026 17:31:36 -0700 Subject: [PATCH] soft delete sections created a delete section button (only accessible to coordinators), archives the section while keeping all of its attendance/enrollment information in the admin data table (using a new "active" attirbute) --- .../coord_interface/CoordSectionDelete.tsx | 77 +++++++++---------- .../components/section/MentorSectionInfo.tsx | 8 +- csm_web/frontend/src/css/section_delete.scss | 19 +++++ csm_web/frontend/src/utils/queries/coord.tsx | 38 +-------- .../frontend/src/utils/queries/sections.tsx | 31 ++++++++ csm_web/scheduler/admin.py | 3 +- .../migrations/0036_section_active.py | 19 +++++ csm_web/scheduler/models.py | 1 + csm_web/scheduler/views/coord.py | 18 +++-- csm_web/scheduler/views/course.py | 44 ++++++----- csm_web/scheduler/views/profile.py | 10 ++- csm_web/scheduler/views/section.py | 11 +-- csm_web/scheduler/views/spacetime.py | 3 +- csm_web/scheduler/views/student.py | 12 ++- csm_web/scheduler/views/waitlistedStudent.py | 16 ++-- 15 files changed, 183 insertions(+), 127 deletions(-) create mode 100644 csm_web/frontend/src/css/section_delete.scss create mode 100644 csm_web/scheduler/migrations/0036_section_active.py diff --git a/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx b/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx index 8c1aedf33..9cf61188e 100644 --- a/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx +++ b/csm_web/frontend/src/components/coord_interface/CoordSectionDelete.tsx @@ -1,55 +1,50 @@ import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; -import { useCoordDeleteSectionMutation } from "../../utils/queries/coord"; -// import Modal from "../Modal"; -import XIcon from "../../../static/frontend/img/x.svg"; +import { useDeleteSectionMutation } from "../../utils/queries/sections"; +import Modal from "../Modal"; +import TrashIcon from "../../../static/frontend/img/trash-alt.svg"; -// import "../../css/student_dropper.scss"; +import "../../css/section_delete.scss"; interface CoordSectionDeleteProps { sectionId: number; } export default function CoordSectionDelete({ sectionId }: CoordSectionDeleteProps) { - const [showDropPrompt, setShowDropPrompt] = useState(false); - const [drop, setDrop] = useState(false); - const [ban, setBan] = useState(false); - const [blacklist, setBlacklist] = useState(false); - - /** - * Mutation to drop a student from the section. (Inspiration taken from dropping students within sections) - */ - const coordSectionDeleteMutation = useCoordDeleteSectionMutation(sectionId); - - function handleClickDrop() { - coordSectionDeleteMutation.mutate({ banned: ban, blacklisted: blacklist }); - setShowDropPrompt(false); + const [showDeletePrompt, setShowDeletePrompt] = useState(false); + const [confirmed, setConfirmed] = useState(false); + const deleteSectionMutation = useDeleteSectionMutation(sectionId); + const navigate = useNavigate(); + + function handleDelete() { + deleteSectionMutation.mutate(undefined, { + onSuccess: () => navigate(-1) + }); } - const dropDiv = ( -
-

DROP Student

-
- setDrop(e.target.checked)} /> - -

-
-
- ); - return ( - // - // setShowDropPrompt(true)} - // /> - //
dropDiv
- - //
+
+ + {showDeletePrompt && ( + setShowDeletePrompt(false)}> +

Delete section

+

This section will be hidden, but its enrollment and attendance history will be preserved.

+ + +
+ )} +
); } diff --git a/csm_web/frontend/src/components/section/MentorSectionInfo.tsx b/csm_web/frontend/src/components/section/MentorSectionInfo.tsx index d3ecddcee..84ce33197 100644 --- a/csm_web/frontend/src/components/section/MentorSectionInfo.tsx +++ b/csm_web/frontend/src/components/section/MentorSectionInfo.tsx @@ -8,6 +8,7 @@ import { } from "../../utils/queries/sections"; import { Mentor, Spacetime, Student } from "../../utils/types"; import LoadingSpinner from "../LoadingSpinner"; +import CoordSectionDelete from "../coord_interface/CoordSectionDelete"; import { CoordinatorAddStudentModal } from "./CoordinatorAddStudentModal"; import MetaEditModal from "./MetaEditModal"; import { InfoCard, SectionSpacetime } from "./Section"; @@ -16,7 +17,7 @@ import SpacetimeEditModal from "./SpacetimeEditModal"; import StudentDropper from "./StudentDropper"; import PencilIcon from "../../../static/frontend/img/pencil.svg"; -import XIcon from "../../../static/frontend/img/x.svg"; +import TrashIcon from "../../../static/frontend/img/trash-alt.svg"; import "../../css/coordinator-add-student.scss"; @@ -162,6 +163,7 @@ export default function MentorSectionInfo({

{`${ isCoordinator ? `${mentor.name || mentor.email}'s` : "My" } Section`}

+ {isCoordinator && }
- Delete +