Course display etwas erweitert.

This commit is contained in:
SJost 2017-10-10 14:46:20 +02:00
parent 3fbeed2682
commit 1fe7362a30
2 changed files with 23 additions and 29 deletions

View File

@ -25,10 +25,9 @@ getCourseListR = redirect TermShowR
getCourseListTermR :: TermIdentifier -> Handler Html getCourseListTermR :: TermIdentifier -> Handler Html
getCourseListTermR tidini = do getCourseListTermR tidini = do
(term,courses) <- runDB $ do (term,courses) <- runDB $ (,)
term <- get $ TermKey tidini <$> get (TermKey tidini)
courses <- selectList [CourseTermId ==. TermKey tidini] [Asc CourseShorthand] <*> selectList [CourseTermId ==. TermKey tidini] [Asc CourseShorthand]
return (term, courses)
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
@ -57,7 +56,12 @@ getCourseListTermR tidini = do
getCourseShowR :: TermIdentifier -> Text -> Handler Html getCourseShowR :: TermIdentifier -> Text -> Handler Html
getCourseShowR tid csh = do 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 let course = entityVal courseEnt
defaultLayout $ do defaultLayout $ do
setTitle $ [shamlet| #{termToText tid} - #{csh}|] setTitle $ [shamlet| #{termToText tid} - #{csh}|]

View File

@ -3,37 +3,27 @@
<div .row> <div .row>
<h1 .header> <h1 .header>
#{courseName course} #{courseName course}
$maybe school <- schoolMB
<h4>
#{schoolName school}
<div .container> <div .container>
<div .bs-docs-section> <div .bs-docs-section>
<div .row> <div .row>
<div .col-lg-12> <div .col-lg-12>
<div .page-header> <div .page-header>
<h1 #start>Beschreibung
$maybe descr <- courseDescription course $maybe descr <- courseDescription course
<h2 #description>Beschreibung
<p> #{descr} <p> #{descr}
$maybe link <- courseLinkExternal course
<h4 #linl>Homepage:
<p> <a href=#{link}>#{link}
You can also use this scaffolded site to explore some concepts, and best practices. <div .row>
<div .col-lg-12>
<h4>Teilnehmer
<li .list-group-item> #{participants}
We can link to other handlers, like the <a href="@{ProfileR}">Profile</a>. $maybe capacity <- courseCapacity course
Try it out as an anonymous user and see the access denied. \ von #{capacity}
Then, try to <a href="@{AuthR LoginR}">login</a> with the dummy authentication added
while in development.
<li .list-group-item>
The HTML you are seeing now is actually composed by a number of <em>widgets</em>, #
most of them are brought together by the <tt>defaultLayout</tt> function which #
is defined in the <tt>Foundation.hs</tt> module,
All the files for templates and wigdets are in <tt>templates</tt>.
<li .list-group-item>
A Widget's Html, Css and Javascript are separated in three files with the
<tt>.hamlet</tt>, <tt>.lucius</tt> and <tt>.julius</tt> extensions.
<hr> <hr>