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
|
when (isNothing term) $ do
|
||||||
setMessage [shamlet| Semester #{termToText tidini} nicht gefunden. |]
|
setMessage [shamlet| Semester #{termToText tidini} nicht gefunden. |]
|
||||||
redirect TermShowR
|
redirect TermShowR
|
||||||
|
-- TODO: several runDBs per TableRow are probably too inefficient!
|
||||||
let colonnadeTerms = mconcat
|
let colonnadeTerms = mconcat
|
||||||
[ headed "Kürzel" $ (\c ->
|
[ headed "Kürzel" $ (\ckv ->
|
||||||
let shd = courseShorthand c
|
let c = entityVal ckv
|
||||||
|
shd = courseShorthand c
|
||||||
tid = unTermKey $ courseTermId c
|
tid = unTermKey $ courseTermId c
|
||||||
in [whamlet| <a href=@{CourseShowR tid shd}>#{shd} |] )
|
in [whamlet| <a href=@{CourseShowR tid shd}>#{shd} |] )
|
||||||
-- , headed "Institut" $ [shamlet| #{course} |]
|
-- , headed "Institut" $ [shamlet| #{course} |]
|
||||||
, headed "Beginn Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterFrom
|
, headed "Beginn Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterFrom.entityVal
|
||||||
, headed "Ende Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterTo
|
, headed "Ende Anmeldung" $ fromString.(maybe "" formatTimeGerWD).courseRegisterTo.entityVal
|
||||||
-- TODO
|
, headed "Teilnehmer" $ (\ckv -> do
|
||||||
-- , headed "Teilnehmer" $ (\c -> do
|
let cid = entityKey ckv
|
||||||
-- let cid = courseId c
|
partiNum <- handlerToWidget $ runDB $ count [CourseParticipantCourseId ==. cid]
|
||||||
-- partiNum <- runDB $ count [CourseParticipantCourseId ==. cid]
|
[whamlet| #{show partiNum} |]
|
||||||
-- return $ fromString $ show partiNum
|
)
|
||||||
-- )
|
, headed " " $ (\ckv ->
|
||||||
, headed " " $ (\c ->
|
let c = entityVal ckv
|
||||||
let shd = courseShorthand c
|
shd = courseShorthand c
|
||||||
tid = unTermKey $ courseTermId c
|
tid = unTermKey $ courseTermId c
|
||||||
in do
|
in do
|
||||||
adminLink <- handlerToWidget $ isAuthorized (CourseEditExistR tid shd ) False
|
adminLink <- handlerToWidget $ isAuthorized (CourseEditExistR tid shd ) False
|
||||||
@ -70,8 +72,8 @@ getCourseListTermR tidini = do
|
|||||||
defaultLinkLayout pageLinks $ do
|
defaultLinkLayout pageLinks $ do
|
||||||
-- defaultLayout $ do
|
-- defaultLayout $ do
|
||||||
setTitle "Semesterkurse"
|
setTitle "Semesterkurse"
|
||||||
linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
|
-- linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
|
||||||
encodeHeadedWidgetTable tableDefault colonnadeTerms (map entityVal courses)
|
encodeHeadedWidgetTable tableDefault colonnadeTerms courses -- (map entityVal courses)
|
||||||
|
|
||||||
getCourseShowR :: TermIdentifier -> Text -> Handler Html
|
getCourseShowR :: TermIdentifier -> Text -> Handler Html
|
||||||
getCourseShowR tid csh = do
|
getCourseShowR tid csh = do
|
||||||
@ -81,7 +83,7 @@ getCourseShowR tid csh = do
|
|||||||
dependent <- (,,)
|
dependent <- (,,)
|
||||||
<$> get (courseSchoolId course) -- join
|
<$> get (courseSchoolId course) -- join
|
||||||
<*> count [CourseParticipantCourseId ==. cid] -- 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
|
Nothing -> return False
|
||||||
(Just aid) -> do
|
(Just aid) -> do
|
||||||
regL <- getBy (UniqueCourseParticipant cid aid)
|
regL <- getBy (UniqueCourseParticipant cid aid)
|
||||||
|
|||||||
Reference in New Issue
Block a user