Skip to content
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

Revert "Aug/add semester popup" #655

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions backend/degree/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from textwrap import dedent

from django.db.models import Q, Subquery
from django.db.models import Q
from rest_framework import serializers

from courses.models import Course
Expand Down Expand Up @@ -143,17 +143,13 @@ def validate(self, data):
for rule in rules:
# NOTE: we don't do any validation if the course doesn't exist in DB. In future,
# it may be better to prompt user for manual override
if Course.objects.filter(full_code=full_code).exists():
satisfying_courses = Course.objects.filter(rule.get_q_object())
if not (
Course.objects.filter(
full_code=full_code,
topic_id__in=Subquery(satisfying_courses.values("topic_id")),
).exists()
):
raise serializers.ValidationError(
f"Course {full_code} does not satisfy rule {rule.id}"
)
if (
Course.objects.filter(full_code=full_code).exists()
and not Course.objects.filter(rule.get_q_object(), full_code=full_code).exists()
):
raise serializers.ValidationError(
f"Course {full_code} does not satisfy rule {rule.id}"
)

# Check for double count restrictions
double_count_restrictions = DoubleCountRestriction.objects.filter(
Expand Down
14 changes: 5 additions & 9 deletions frontend/degree-plan/components/Dock/Dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ const DockContainer = styled.div<{$isDroppable:boolean, $isOver: boolean}>`
const SearchIconContainer = styled.div`
padding: .25rem 2rem;
padding-left: 0;
border-color: var(--primary-color-xx-dark);
color: var(--primary-color-extra-dark);
border-color: var(--primary-color-extra-dark);
border-width: 0;
border-right-width: 2px;
border-style: solid;
flex-shrink: 0;
display: flex;
gap: 1rem;
`

const DockedCoursesWrapper = styled.div`
Expand Down Expand Up @@ -109,7 +106,7 @@ const Dock = ({ user, login, logout, activeDegreeplanId }: DockProps) => {
// const [courseAdded, setCourseAdded] = React.useState(false);
const { searchPanelOpen, setSearchPanelOpen, setSearchRuleQuery, setSearchRuleId } = useContext(SearchPanelContext)
const { createOrUpdate } = useSWRCrud<DockedCourse>(`/api/degree/docked`, { idKey: 'full_code' });
const { data: dockedCourses = [], isLoading } = useSWR<DockedCourse[]>(user ? `/api/degree/docked` : null);
const {data: dockedCourses = [], isLoading} = useSWR<DockedCourse[]>(user ? `/api/degree/docked` : null);

// Returns a boolean that indiates whether this is the first render
const useIsMount = () => {
Expand All @@ -120,6 +117,8 @@ const Dock = ({ user, login, logout, activeDegreeplanId }: DockProps) => {
return isMountRef.current;
};

const isMount = useIsMount();

const [{ isOver, canDrop }, drop] = useDrop(() => ({
accept: [ItemTypes.COURSE_IN_PLAN, ItemTypes.COURSE_IN_REQ],
drop: (course: DnDCourse) => {
Expand Down Expand Up @@ -161,11 +160,8 @@ const Dock = ({ user, login, logout, activeDegreeplanId }: DockProps) => {
setSearchPanelOpen(!searchPanelOpen);
}}>
<DarkBlueIcon>
<i className="fas fa-plus fa-lg"/>
<i className="fas fa-search fa-lg"/>
</DarkBlueIcon>
<div>
Add Course
</div>
</SearchIconContainer>
<DockedCoursesWrapper>
{isLoading ?
Expand Down
14 changes: 6 additions & 8 deletions frontend/degree-plan/components/FourYearPlan/DegreeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export type ModalKey =
| "degree-add"
| "degree-remove"
| "semester-remove"
| "semester-add"
| null; // null is closed

const getModalTitle = (modalState: ModalKey) => {
Expand All @@ -51,7 +50,7 @@ const getModalTitle = (modalState: ModalKey) => {
}
};

export const ModalInteriorWrapper = styled.div<{ $row?: boolean }>`
const ModalInteriorWrapper = styled.div<{ $row?: boolean }>`
display: flex;
flex-direction: ${(props) => (props.$row ? "row" : "column")};
align-items: center;
Expand All @@ -75,7 +74,7 @@ const ModalText = styled.div`
font-size: 0.87rem;
`;

export const ModalButton = styled.button`
const ModalButton = styled.button`
margin: 0px 0px 0px 0px;
height: 32px;
width: 5rem;
Expand All @@ -86,15 +85,15 @@ export const ModalButton = styled.button`
border: none;
`;

export const ButtonRow = styled.div<{ $center?: boolean }>`
const ButtonRow = styled.div<{ $center?: boolean }>`
display: flex;
width: 100%;
flex-direction: row;
justify-content: ${(props) => (props.$center ? "center" : "flex-end")};
gap: 0.5rem;
`;

export const CancelButton = styled.button`
const CancelButton = styled.button`
margin: 0px 0px 0px 0px;
height: 29px;
width: 4rem;
Expand Down Expand Up @@ -141,12 +140,12 @@ interface RemoveSemesterProps {

interface ModalInteriorProps {
modalKey: ModalKey;
modalObject: DegreePlan | null | RemoveSemesterProps | RemoveDegreeProps | Degree | HTMLElement;
modalObject: DegreePlan | null | RemoveSemesterProps | RemoveDegreeProps | Degree;
setActiveDegreeplan: (arg0: DegreePlan | null) => void;
close: () => void;
modalRef: React.RefObject<HTMLSelectElement | null>;
}
export const ModalInterior = ({
const ModalInterior = ({
modalObject,
modalKey,
setActiveDegreeplan,
Expand Down Expand Up @@ -391,4 +390,3 @@ const DegreeModal = ({
);

export default DegreeModal;

28 changes: 2 additions & 26 deletions frontend/degree-plan/components/FourYearPlan/PlanPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const ShowStatsText = styled.div`
min-width: 6rem;
`

const AddSemText = styled.div`
min-width: 8rem;
`

const ShowStatsButton = ({ showStats, setShowStats }: { showStats: boolean, setShowStats: (arg0: boolean) => void }) => (
<PanelTopBarButton onClick={() => setShowStats(!showStats)}>
<PanelTopBarIcon>
Expand All @@ -28,22 +24,6 @@ const ShowStatsButton = ({ showStats, setShowStats }: { showStats: boolean, setS
</PanelTopBarButton>
);

interface AddSemesterButtonProp {
editMode: boolean,
setShowAddSemModal: (arg0: boolean) => void
}

const AddSemesterButton = ({editMode, setShowAddSemModal} : AddSemesterButtonProp) => editMode && (
<PanelTopBarButton onClick={() => setShowAddSemModal(true)}>
<PanelTopBarIcon>
<i className={`fas fa-plus fa-md`}/>
</PanelTopBarIcon>
<AddSemText>
Add Semester
</AddSemText>
</PanelTopBarButton>
)

interface PlanPanelProps {
setModalKey: (arg0: ModalKey) => void;
modalKey: string | null;
Expand All @@ -70,7 +50,6 @@ const PlanPanel = ({
const { copy: copyDegreeplan } = useSWRCrud<DegreePlan>('/api/degree/degreeplans');
const [showStats, setShowStats] = useState(true);
const [editMode, setEditMode] = useState(false);
const [showAddSemModal, setShowAddSemModal] = useState(false);

return (
<PanelContainer>
Expand Down Expand Up @@ -101,20 +80,17 @@ const PlanPanel = ({
isLoading={isLoading}
/>
<PanelTopBarIconList>
<AddSemesterButton editMode={editMode} setShowAddSemModal={setShowAddSemModal}/>
<ShowStatsButton showStats={showStats} setShowStats={setShowStats} />
<EditButton editMode={editMode} setEditMode={setEditMode}/>
<EditButton editMode={editMode} setEditMode={setEditMode} />
</PanelTopBarIconList>
</PanelHeader>
{/** map to semesters */}
<PanelBody>
<Semesters
<Semesters
activeDegreeplan={activeDegreeplan || undefined}
showStats={showStats}
editMode={editMode}
setEditMode={setEditMode}
showAddSemModal={showAddSemModal}
setShowAddSemModal={setShowAddSemModal}
setModalKey={setModalKey}
setModalObject={setModalObject}
isLoading={isLoading}
Expand Down
Loading
Loading