chore(term): course list filtered by default to active term

This commit is contained in:
Steffen Jost 2024-01-25 16:40:07 +01:00
parent d332c0c11a
commit 28837c41ab
2 changed files with 11 additions and 2 deletions

View File

@ -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")

View File

@ -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