From 1fe7362a30c9a22174842d073fcbf217afd2d58e Mon Sep 17 00:00:00 2001 From: SJost Date: Tue, 10 Oct 2017 14:46:20 +0200 Subject: [PATCH] Course display etwas erweitert. --- src/Handler/Course.hs | 14 +++++++++----- templates/course.hamlet | 38 ++++++++++++++------------------------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index 71c7c54cf..eeb179e33 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -25,10 +25,9 @@ getCourseListR = redirect TermShowR getCourseListTermR :: TermIdentifier -> Handler Html getCourseListTermR tidini = do - (term,courses) <- runDB $ do - term <- get $ TermKey tidini - courses <- selectList [CourseTermId ==. TermKey tidini] [Asc CourseShorthand] - return (term, courses) + (term,courses) <- runDB $ (,) + <$> get (TermKey tidini) + <*> selectList [CourseTermId ==. TermKey tidini] [Asc CourseShorthand] when (isNothing term) $ do setMessage [shamlet| Semester #{termToText tidini} nicht gefunden. |] redirect TermShowR @@ -57,7 +56,12 @@ getCourseListTermR tidini = do getCourseShowR :: TermIdentifier -> Text -> Handler Html getCourseShowR tid csh = do - courseEnt <- runDB $ getBy404 $ CourseTermShort (TermKey tid) csh + (courseEnt,(schoolMB,participants)) <- runDB $ do + courseEnt@(Entity cid course) <- getBy404 $ CourseTermShort (TermKey tid) csh + dependent <- (,) + <$> get (courseSchoolId course) + <*> count [CourseParticipantCourseId ==. cid] + return $ (courseEnt,dependent) let course = entityVal courseEnt defaultLayout $ do setTitle $ [shamlet| #{termToText tid} - #{csh}|] diff --git a/templates/course.hamlet b/templates/course.hamlet index d4e2612f7..8b2073aa2 100644 --- a/templates/course.hamlet +++ b/templates/course.hamlet @@ -3,37 +3,27 @@

#{courseName course} - + $maybe school <- schoolMB +

+ #{schoolName school}
-
-

Beschreibung +
$maybe descr <- courseDescription course +

Beschreibung

#{descr} - - -

- You can also use this scaffolded site to explore some concepts, and best practices. - - -

  • - We can link to other handlers, like the Profile. - Try it out as an anonymous user and see the access denied. - Then, try to login with the dummy authentication added - while in development. - -
  • - The HTML you are seeing now is actually composed by a number of widgets, # - most of them are brought together by the defaultLayout function which # - is defined in the Foundation.hs module, - All the files for templates and wigdets are in templates. - -
  • - A Widget's Html, Css and Javascript are separated in three files with the - .hamlet, .lucius and .julius extensions. + $maybe link <- courseLinkExternal course +

    Homepage: + #{link} +
    +
    +

    Teilnehmer + #{participants} + $maybe capacity <- courseCapacity course + \ von #{capacity}