From 86204f78e2391c32b2cf6c9716de6c9cb738168b Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Thu, 16 May 2019 13:58:07 +0200 Subject: [PATCH] attempt at #374 failed --- src/Handler/Corrections.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 34530d0e8..536ebb35a 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -200,6 +200,35 @@ colCommentField = sortable (Just "comment") (i18nCell MsgRatingComment) $ formCe (\DBRow{ dbrOutput=(Entity subId _, _, _, _, _) } -> return subId) (\DBRow{ dbrOutput=(Entity _ Submission{..}, _, _, _, _) } mkUnique -> over (_1.mapped) ((_3 .~) . assertM (not . null) . fmap (Text.strip . unTextarea)) . over _2 fvInput <$> mopt textareaField (fsUniq mkUnique "comment") (Just $ Textarea <$> submissionRatingComment)) +colLastEdit :: Colonnade Sortable CorrectionTableData (DBCell _ (FormResult (DBFormResult SubmissionId (a, b, Maybe Text) CorrectionTableData))) +colLastEdit = sortable (Just "last-edit") (i18nCell MsgLastEdit) $ + \DBRow{ dbrOutput=(Entity subId _, _, _, _, _) } -> sqlCell $ do + edits <- E.select $ E.from $ \edit -> do + E.where_ $ edit E.^. SubmissionEditSubmission E.==. E.val subId + return $ E.max_ $ edit E.^. SubmissionEditTime + return [whamlet| + $newline never + DATES + $forall ed <- edits + #{show ed} + |] + +-- colLastEdit' :: Colonnade Sortable CorrectionTableData (DBCell _ (FormResult (DBFormResult SubmissionId (a, b, Maybe Text) CorrectionTableData))) +-- colLastEdit' = sortable (Just "last-edit") (i18nCell MsgLastEdit) $ (formCell id +-- (\DBRow{ dbrOutput=(Entity subId _, _, _, _, _) } -> return subId) +-- (const mempty)) +-- -- \DBRow{ dbrOutput=(Entity subId _, _, _, _, _) } -> sqlCell $ do +-- -- edits <- E.select $ E.from $ \edit -> do +-- -- E.where_ $ edit E.^. SubmissionEditSubmission E.==. E.val subId +-- -- return $ E.max_ $ edit E.^. SubmissionEditTime +-- -- return [whamlet| +-- -- $newline never +-- -- DATES +-- -- $forall ed <- edits +-- -- #{show ed} +-- -- |] + + makeCorrectionsTable :: ( IsDBTable m x, ToSortable h, Functor h ) => CorrectionTableWhere -> Colonnade h CorrectionTableData (DBCell m x) -> _ -> PSValidator m x -> _ -> DBParams m x -> DB (DBResult m x) @@ -551,6 +580,8 @@ postCCorrectionsR tid ssh csh = do , colSMatrikel , colSubmittors , colSubmissionLink + -- , colLastEdit -- this does not type + -- , colLastEdit' , colRating , colRated , colCorrector