Course participant count working now, albeit inefficient through runDB per Collonade-Row
This commit is contained in:
parent
c09b0d8619
commit
70ad55f565
@ -33,22 +33,24 @@ getCourseListTermR tidini = do
|
||||
when (isNothing term) $ do
|
||||
setMessage [shamlet| Semester #{termToText tidini} nicht gefunden. |]
|
||||
redirect TermShowR
|
||||
-- TODO: several runDBs per TableRow are probably too inefficient!
|
||||
let colonnadeTerms = mconcat
|
||||
[ headed "Kürzel" $ (\c ->
|
||||
let shd = courseShorthand c
|
||||
[ headed "Kürzel" $ (\ckv ->
|
||||
let c = entityVal ckv
|
||||
shd = courseShorthand c
|
||||
tid = unTermKey $ courseTermId c
|
||||
in [whamlet| <a href=@{CourseShowR tid shd}>#{shd} |] )
|
||||
-- , headed "Institut" $ [shamlet| #{course} |]
|
||||
, headed "Beginn Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterFrom
|
||||
, headed "Ende Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterTo
|
||||
-- TODO
|
||||
-- , headed "Teilnehmer" $ (\c -> do
|
||||
-- let cid = courseId c
|
||||
-- partiNum <- runDB $ count [CourseParticipantCourseId ==. cid]
|
||||
-- return $ fromString $ show partiNum
|
||||
-- )
|
||||
, headed " " $ (\c ->
|
||||
let shd = courseShorthand c
|
||||
, headed "Beginn Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterFrom.entityVal
|
||||
, headed "Ende Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterTo.entityVal
|
||||
, headed "Teilnehmer" $ (\ckv -> do
|
||||
let cid = entityKey ckv
|
||||
partiNum <- handlerToWidget $ runDB $ count [CourseParticipantCourseId ==. cid]
|
||||
[whamlet| #{show partiNum} |]
|
||||
)
|
||||
, headed " " $ (\ckv ->
|
||||
let c = entityVal ckv
|
||||
shd = courseShorthand c
|
||||
tid = unTermKey $ courseTermId c
|
||||
in do
|
||||
adminLink <- handlerToWidget $ isAuthorized (CourseEditExistR tid shd ) False
|
||||
@ -70,8 +72,8 @@ getCourseListTermR tidini = do
|
||||
defaultLinkLayout pageLinks $ do
|
||||
-- defaultLayout $ do
|
||||
setTitle "Semesterkurse"
|
||||
linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
|
||||
encodeHeadedWidgetTable tableDefault colonnadeTerms (map entityVal courses)
|
||||
-- linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
|
||||
encodeHeadedWidgetTable tableDefault colonnadeTerms courses -- (map entityVal courses)
|
||||
|
||||
getCourseShowR :: TermIdentifier -> Text -> Handler Html
|
||||
getCourseShowR tid csh = do
|
||||
@ -81,7 +83,7 @@ getCourseShowR tid csh = do
|
||||
dependent <- (,,)
|
||||
<$> get (courseSchoolId course) -- join
|
||||
<*> count [CourseParticipantCourseId ==. cid] -- join
|
||||
<*> (case mbAid of -- Someone please refactor this late-night mess here!
|
||||
<*> (case mbAid of -- TODO: Someone please refactor this late-night mess here!
|
||||
Nothing -> return False
|
||||
(Just aid) -> do
|
||||
regL <- getBy (UniqueCourseParticipant cid aid)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user