diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs index 9ca32da9d..0fc8a4d87 100644 --- a/src/Handler/Term.hs +++ b/src/Handler/Term.hs @@ -1,4 +1,8 @@ -module Handler.Term where +module Handler.Term + ( getTermShowR + , getTermEditR, postTermEditR + , getTermEditExistR, postTermEditExistR + ) where import Import import Handler.Utils @@ -31,110 +35,101 @@ validateTerm = do guardValidation MsgTermEndMustBeAfterLectureEnd $ termEnd >= termLectureEnd -getTermShowR :: Handler TypedContent +getTermShowR :: Handler Html getTermShowR = do --- terms <- runDB $ selectList [] [Desc TermStart] -------- ÄQUIVALENT: --- term <- runDB $ E.select . E.from $ \(term) -> do --- E.orderBy [E.desc $ term E.^. TermStart ] --- return term --- - let - termData :: E.SqlExpr (Entity Term) -> E.SqlQuery (E.SqlExpr (Entity Term), E.SqlExpr (E.Value Int64)) - termData term = do - -- E.orderBy [E.desc $ term E.^. TermStart ] - let courseCount = E.subSelectCount . E.from $ \course -> - E.where_ $ term E.^. TermId E.==. course E.^. CourseTerm - return (term, courseCount) - selectRep $ do - provideRep $ toJSON . map fst <$> runDB (E.select $ E.from termData) - provideRep $ do - let colonnadeTerms = widgetColonnade $ mconcat - [ sortable (Just "term-id") (i18nCell MsgTermShort) $ \(Entity tid _, _) -> anchorCell - (TermCourseListR tid) - [whamlet|#{toPathPiece tid}|] - , sortable (Just "lecture-start") (i18nCell MsgLectureStart) $ \(Entity _ Term{..},_) -> - cell $ formatTime SelFormatDate termLectureStart >>= toWidget - , sortable (Just "lecture-end") (i18nCell MsgTermLectureEnd) $ \(Entity _ Term{..},_) -> - cell $ formatTime SelFormatDate termLectureEnd >>= toWidget - , sortable Nothing (i18nCell MsgTermActive) $ \(Entity _ Term{..},_) -> - tickmarkCell termActive - , sortable Nothing (i18nCell MsgTermCourseCount) $ \(_, E.Value numCourses) -> - cell [whamlet|_{MsgNumCourses numCourses}|] - , sortable (Just "start") (i18nCell MsgTermStart) $ \(Entity _ Term{..},_) -> - cell $ formatTime SelFormatDate termStart >>= toWidget - , sortable (Just "end") (i18nCell MsgTermEnd) $ \(Entity _ Term{..},_) -> - cell $ formatTime SelFormatDate termEnd >>= toWidget - , sortable Nothing (i18nCell MsgTermHolidays) $ \(Entity _ Term{..},_) -> - cell $ do - termHolidays' <- mapM (formatTime SelFormatDate) termHolidays - [whamlet| - $newline never -