From 21e0c5b4dcc4653b9c7d7bd15e08687a476506bd Mon Sep 17 00:00:00 2001 From: SJost Date: Tue, 3 Jul 2018 11:24:31 +0200 Subject: [PATCH] Bugfix: Weekdays correct now; Homepage edited. --- src/Handler/Home.hs | 28 +++++++++++++++++----------- src/Handler/Sheet.hs | 2 +- src/Handler/Term.hs | 30 +++++++++++++++++------------- src/Handler/Utils/DateTime.hs | 9 +++++---- templates/home.hamlet | 4 ++-- templates/homeUser.hamlet | 7 ++++--- 6 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index 4e68486af..931a93ff9 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -62,10 +62,6 @@ homeAnonymous = do E.&&. ((E.isNothing $ course E.^. CourseRegisterTo) E.||. (course E.^. CourseRegisterTo E.>=. E.val (Just cTime))) E.limit nrSheetDeadlines - E.orderBy [ E.asc $ course E.^. CourseRegisterTo - , E.desc $ course E.^. CourseShorthand - ] - E.limit nrSheetDeadlines return course colonnade :: Colonnade Sortable (DBRow (Entity Course)) (DBCell (WidgetT UniWorX IO) ()) @@ -75,7 +71,9 @@ homeAnonymous = do let tid = courseTerm course csh = courseShorthand course cell [whamlet|#{display csh}|] - , sortable (Just "deadline") (i18nCell MsgRegisterTo) $ \DBRow{ dbrOutput=(Entity {entityVal = course}) } -> + , sortable (Just "term") (textCell MsgTerm) $ \DBRow{ dbrOutput=(Entity {entityVal = course}) } -> + textCell $ display $ courseTerm course + , sortable (Just "deadline") (textCell MsgRegisterTo) $ \DBRow{ dbrOutput=(Entity {entityVal = course}) } -> textCell $ display $ courseRegisterTo course ] courseTable <- dbTable def $ DBTable @@ -88,7 +86,9 @@ homeAnonymous = do , ( "course" , SortColumn $ \(course) -> course E.^. CourseShorthand ) - -- TODO + , ( "deadline" + , SortColumn $ \(course) -> course E.^. CourseRegisterTo + ) ] , dbtFilter = mempty {- [ ( "term" , FilterColumn $ \(course `E.InnerJoin` _ `E.InnerJoin` _ ) tids -> if @@ -122,10 +122,6 @@ homeUser uid = do E.where_ $ participant E.^. CourseParticipantUser E.==. E.val uid E.&&. sheet E.^. SheetActiveTo E.<=. E.val fTime E.&&. sheet E.^. SheetActiveTo E.>=. E.val cTime - E.orderBy [ E.asc $ sheet E.^. SheetActiveTo - , E.desc $ sheet E.^. SheetName - , E.desc $ course E.^. CourseShorthand - ] E.limit nrSheetDeadlines return ( course E.^. CourseTerm @@ -139,6 +135,8 @@ homeUser uid = do [ -- dbRow sortable (Just "course") (textCell MsgCourse) $ \DBRow{ dbrOutput=(E.Value tid, E.Value csh, _, _) } -> cell [whamlet|#{display csh}|] + , sortable (Just "term") (textCell MsgTerm) $ \DBRow{ dbrOutput=(E.Value tid, _,_,_) } -> + textCell $ display tid , sortable (Just "sheet") (textCell MsgSheet) $ \DBRow{ dbrOutput=(E.Value tid, E.Value csh, E.Value shn, _) } -> cell [whamlet|#{display shn}|] , sortable (Just "deadline") (textCell MsgDeadline) $ \DBRow{ dbrOutput=(_, _, _, E.Value deadline) } -> @@ -156,7 +154,15 @@ homeUser uid = do , ( "course" , SortColumn $ \(_ `E.InnerJoin` course `E.InnerJoin` _ ) -> course E.^. CourseShorthand ) - -- TODO + , ( "sheet" + , SortColumn $ \(_ `E.InnerJoin` _ `E.InnerJoin` sheet ) -> sheet E.^. SheetName + ) + , ( "deadline" + , SortColumn $ \(_ `E.InnerJoin` _ `E.InnerJoin` sheet ) -> sheet E.^. SheetActiveTo + ) + , ( "done" + , SortColumn $ \(_ `E.InnerJoin` _ `E.InnerJoin` sheet ) -> sheet E.^. SheetActiveTo + ) ] , dbtFilter = mempty {- [ ( "term" , FilterColumn $ \(course `E.InnerJoin` _ `E.InnerJoin` _ ) tids -> if diff --git a/src/Handler/Sheet.hs b/src/Handler/Sheet.hs index 3da6d34e7..4e97d5c1c 100644 --- a/src/Handler/Sheet.hs +++ b/src/Handler/Sheet.hs @@ -165,7 +165,7 @@ getSheetList courseEnt = do let colBase = mconcat [ headed "Blatt" $ \(sid,sheet,_) -> simpleLink (toWgt $ sheetName sheet) $ CSheetR tid csh (sheetName sheet) SShowR , headed "Abgabe ab" $ toWgt . formatTimeGerWD . sheetActiveFrom . snd3 - , headed "Abgabe lbis" $ toWgt . formatTimeGerWD . sheetActiveTo . snd3 + , headed "Abgabe bis" $ toWgt . formatTimeGerWD . sheetActiveTo . snd3 , headed "Bewertung" $ toWgt . display . sheetType . snd3 ] let colAdmin = mconcat -- only show edit button for allowed course assistants diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs index 86c24f955..877efce34 100644 --- a/src/Handler/Term.hs +++ b/src/Handler/Term.hs @@ -42,25 +42,17 @@ getTermShowR = do provideRep $ toJSON . map fst <$> runDB (E.select $ E.from termData) provideRep $ do let colonnadeTerms = widgetColonnade $ mconcat - [ sortable Nothing "Kürzel" $ \(Entity tid Term{..},_) -> cell $ do - -- Scrap this if to slow, create term edit page instead - adminLink <- handlerToWidget $ isAuthorized (TermEditExistR tid) False - [whamlet| - $if adminLink == Authorized - - #{termToText termName} - $else - #{termToText termName} - |] + [ sortable Nothing "Kürzel" $ + anchorCell (\(Entity tid _, _) -> TermCourseListR tid) + (\(Entity tid _, _) -> [whamlet|#{display tid}|]) , sortable (Just "lecture-start") (i18nCell MsgLectureStart) $ \(Entity _ Term{..},_) -> stringCell $ formatTimeGerWD termLectureStart , sortable (Just "lecture-end") "Ende Vorlesungen" $ \(Entity _ Term{..},_) -> stringCell $ formatTimeGerWD termLectureEnd , sortable Nothing "Aktiv" $ \(Entity _ Term{..},_) -> textCell $ (bool "" tickmark termActive :: Text) - , sortable Nothing "Kursliste" $ anchorCell - (\(Entity tid _, _) -> TermCourseListR tid) - (\(_, E.Value numCourses) -> [whamlet|_{MsgNumCourses numCourses}|]) + , sortable Nothing "Kurse" $ \(_, E.Value numCourses) -> + cell [whamlet|_{MsgNumCourses numCourses}|] , sortable (Just "start") "Semesteranfang" $ \(Entity _ Term{..},_) -> stringCell $ formatTimeGerWD termStart , sortable (Just "end") "Semesterende" $ \(Entity _ Term{..},_) -> @@ -68,6 +60,18 @@ getTermShowR = do , sortable Nothing "Feiertage im Semester" $ \(Entity _ Term{..},_) -> stringCell $ (intercalate ", ") $ map formatTimeGerWD termHolidays ] +-- let adminColonnade = +-- [ sortable Nothing "Edit" $ \(Entity tid Term{..},_) -> cell $ do +-- -- Scrap this if to slow, create term edit page instead +-- adminLink <- handlerToWidget $ isAuthorized (TermEditExistR tid) False +-- [whamlet| +-- $if adminLink == Authorized +-- +-- #{termToText termName} +-- $else +-- #{termToText termName} +-- |] +-- ] table <- dbTable def $ DBTable { dbtSQLQuery = termData , dbtColonnade = colonnadeTerms diff --git a/src/Handler/Utils/DateTime.hs b/src/Handler/Utils/DateTime.hs index af8bfa639..4e693c9d6 100644 --- a/src/Handler/Utils/DateTime.hs +++ b/src/Handler/Utils/DateTime.hs @@ -5,13 +5,13 @@ import Data.Time germanTimeLocale :: TimeLocale germanTimeLocale = TimeLocale - { wDays = [("Montag" ,"Mo") + { wDays = [("Sonntag" ,"So") + ,("Montag" ,"Mo") ,("Dienstag" ,"Di") ,("Mittwoch" ,"Mi") ,("Donnerstag" ,"Do") ,("Freitag" ,"Fr") ,("Samstag" ,"Sa") - ,("Sonntag" ,"So") ] , months = [("Januar" ,"Jan") ,("Februar" ,"Feb") @@ -46,8 +46,9 @@ formatTimeGerWDT = formatTimeGer $ dateTimeFmt germanTimeLocale formatTimeGerDT :: FormatTime t => t -> String -- 0.00.00 0:00 formatTimeGerDT = formatTimeGer "%e.%m.%y %k:%M" -- leading spaces at start, otherwise 0 padding -formatTimeGerDT2 :: FormatTime t => t -> String -- 00.00.00 00:00 -formatTimeGerDT2 = formatTimeGer "%d.%m.%y %H:%M" -- always padding with 0 +-- the following is used by DisplayAble's display: +formatTimeGerDT2 :: FormatTime t => t -> String -- Day 00.00.00 00:00 +formatTimeGerDT2 = formatTimeGer "%a %d.%m.%y %H:%M" -- always padding with 0 formatTimeGerWD :: FormatTime t => t -> String formatTimeGerWD = formatTimeGer "%a %e.%m.%y" diff --git a/templates/home.hamlet b/templates/home.hamlet index 67529c3c7..d89262014 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -9,8 +9,8 @@

Kurse mit offener Registrierung -
- ^{courseTable} +
+ ^{courseTable}

Re-Implementierung von UniWorX diff --git a/templates/homeUser.hamlet b/templates/homeUser.hamlet index 9ed3f93d3..d4640e016 100644 --- a/templates/homeUser.hamlet +++ b/templates/homeUser.hamlet @@ -9,9 +9,10 @@ Die Implementierung von Uni2work ist noch nicht abgeschlossen. -

Anstehende Übungsblätter -
- ^{sheetTable} +

+ Anstehende Übungsblätter +
+ ^{sheetTable}