From 28837c41ab5dcb7ea9610429c63fe95118a547aa Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Thu, 25 Jan 2024 16:40:07 +0100 Subject: [PATCH] chore(term): course list filtered by default to active term --- src/Handler/Course/List.hs | 11 ++++++++++- src/Handler/Course/ParticipantInvite.hs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Handler/Course/List.hs b/src/Handler/Course/List.hs index 513e63f87..1a8784748 100644 --- a/src/Handler/Course/List.hs +++ b/src/Handler/Course/List.hs @@ -226,7 +226,16 @@ getCourseListR = do ] validator = def & defaultSorting [SortDescBy "term",SortAscBy "course"] - coursesTable <- runDB $ makeCourseTable colonnade validator + now <- liftIO getCurrentTime + coursesTable <- runDB $ do + activeTs <- selectList [TermActiveFrom <=. now + , FilterOr [TermActiveTo >. Just now, TermActiveTo ==. Nothing] + , FilterOr [TermActiveFor ==. muid, TermActiveFor ==. Nothing] -- TermActiveFor <-. [Nothing, muid] did not work as intended + ] [Desc TermActiveTerm] + let addTermFilter = if null activeTs + then id + else defaultFilter $ singletonMap "term" [toPathPiece termActiveTerm | Entity _ TermActive{termActiveTerm} <- activeTs] + makeCourseTable colonnade (validator & addTermFilter) defaultLayout $ do setTitleI MsgCourseListTitle $(widgetFile "courses") diff --git a/src/Handler/Course/ParticipantInvite.hs b/src/Handler/Course/ParticipantInvite.hs index 8172b21bd..0ce1e516b 100644 --- a/src/Handler/Course/ParticipantInvite.hs +++ b/src/Handler/Course/ParticipantInvite.hs @@ -193,7 +193,7 @@ handleAddUserR tid ssh csh tdesc ttyp = do currentRoute <- fromMaybe (error "postCAddUserR called from 404-handler") <$> getCurrentRoute (_ , registerConfirmResult) <- runButtonForm FIDCourseRegisterConfirm - $logDebugS "***AbortProblem***" $ tshow registerConfirmResult + -- $logDebugS "***AbortProblem***" $ tshow registerConfirmResult case registerConfirmResult of Nothing -> return () (Just BtnCourseRegisterAbort) -> addMessageI Warning MsgAborted