From 0a433f06a5c05554d42bb6c56b3e12071818a22e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 21 Jun 2018 11:18:01 +0200 Subject: [PATCH] examplary course-shorthand-filter in terms-list --- src/Handler/Term.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs index f09bc9e9a..59c103e28 100644 --- a/src/Handler/Term.hs +++ b/src/Handler/Term.hs @@ -87,6 +87,13 @@ getTermShowR = do , dbtFilter = [ ( "active" , FilterColumn $ \term -> (term E.^. TermActive :: E.SqlExpr (E.Value Bool)) ) + , ( "course" + , FilterColumn $ \term csh -> case csh of -- FilterColumn-Lambdas are + [] -> E.val True :: E.SqlExpr (E.Value Bool) + cshs -> E.exists . E.from $ \course -> do + E.where_ $ course E.^. CourseTerm E.==. term E.^. TermId + E.&&. course E.^. CourseShorthand `E.in_` E.valList cshs + ) ] , dbtAttrs = tableDefault , dbtIdent = "terms" :: Text