Towards #298
This commit is contained in:
parent
04e37a9ae7
commit
2feb751afa
@ -519,9 +519,9 @@ CorrectorMissing: Abwesend
|
|||||||
CorrectorExcused: Entschuldigt
|
CorrectorExcused: Entschuldigt
|
||||||
CorrectorStateTip: Abwesende Korrektoren bekommen bei späteren Übungsblättern mehr Korrekturen zum Ausgleich zugewiesen. Entschuldigte Korrektoren müssen nicht nacharbeiten.
|
CorrectorStateTip: Abwesende Korrektoren bekommen bei späteren Übungsblättern mehr Korrekturen zum Ausgleich zugewiesen. Entschuldigte Korrektoren müssen nicht nacharbeiten.
|
||||||
|
|
||||||
DayIsAHoliday tid@TermId date@Text: #{date} ist ein Feiertag
|
DayIsAHoliday tid@TermId name@Text date@Text: Datum für "#{name}" ist ein Feiertag: #{date}
|
||||||
DayIsOutOfLecture tid@TermId date@Text: #{date} ist außerhalb der Vorlesungszeit des #{display tid}
|
DayIsOutOfLecture tid@TermId name@Text date@Text: Datum für "#{name}" ist außerhalb der Vorlesungszeit des #{display tid}: #{date}
|
||||||
DayIsOutOfTerm tid@TermId date@Text: #{date} liegt nicht im #{display tid}
|
DayIsOutOfTerm tid@TermId name@Text date@Text: Datum für "#{name}" liegt nicht im Semester #{display tid}: #{date}
|
||||||
|
|
||||||
UploadModeNone: Kein Upload
|
UploadModeNone: Kein Upload
|
||||||
UploadModeAny: Upload, beliebige Datei(en)
|
UploadModeAny: Upload, beliebige Datei(en)
|
||||||
|
|||||||
@ -802,9 +802,10 @@ postCorrectionsUploadR = do
|
|||||||
(Just subs)
|
(Just subs)
|
||||||
| null subs -> addMessageI Warning MsgNoCorrectionsUploaded
|
| null subs -> addMessageI Warning MsgNoCorrectionsUploaded
|
||||||
| otherwise -> do
|
| otherwise -> do
|
||||||
subs' <- traverse encrypt $ Set.toList subs :: Handler [CryptoFileNameSubmission]
|
subs' <- traverse (\x -> (,) <$> encrypt x <*> encrypt x) $ Set.toList subs :: Handler [(CryptoFileNameSubmission, CryptoUUIDSubmission)]
|
||||||
mr <- (toHtml .) <$> getMessageRender
|
let trigger = [whamlet|_{MsgCorrectionsUploaded (genericLength subs')}|]
|
||||||
addMessage Success =<< withUrlRenderer ($(ihamletFile "templates/messages/correctionsUploaded.hamlet") mr)
|
content = Right $(widgetFile "messages/correctionsUploaded")
|
||||||
|
addMessageModal Success trigger content
|
||||||
|
|
||||||
let uploadForm = wrapForm upload def
|
let uploadForm = wrapForm upload def
|
||||||
{ formAction = Just $ SomeRoute CorrectionsUploadR
|
{ formAction = Just $ SomeRoute CorrectionsUploadR
|
||||||
@ -1008,8 +1009,10 @@ postCorrectionsGradeR = do
|
|||||||
, SubmissionRatingTime =. now <$ guard rated
|
, SubmissionRatingTime =. now <$ guard rated
|
||||||
]
|
]
|
||||||
| otherwise -> return Nothing
|
| otherwise -> return Nothing
|
||||||
subs' <- traverse encrypt subs :: Handler [CryptoFileNameSubmission]
|
subs' <- traverse (\x -> (,) <$> encrypt x <*> encrypt x) subs :: Handler [(CryptoFileNameSubmission, CryptoUUIDSubmission)]
|
||||||
unless (null subs') $(addMessageFile Success "templates/messages/correctionsUploaded.hamlet")
|
let trigger = [whamlet|_{MsgCorrectionsUploaded (genericLength subs')}|]
|
||||||
|
content = Right $(widgetFile "messages/correctionsUploaded")
|
||||||
|
unless (null subs') $ addMessageModal Success trigger content
|
||||||
|
|
||||||
defaultLayout $
|
defaultLayout $
|
||||||
$(widgetFile "corrections-grade")
|
$(widgetFile "corrections-grade")
|
||||||
|
|||||||
@ -580,14 +580,25 @@ handleSheetEdit tid ssh csh msId template dbAction = do
|
|||||||
insert_ $ SheetEdit aid actTime sid
|
insert_ $ SheetEdit aid actTime sid
|
||||||
addMessageI Success $ MsgSheetEditOk tid ssh csh sfName
|
addMessageI Success $ MsgSheetEditOk tid ssh csh sfName
|
||||||
-- Sanity checks generating warnings only, but not errors!
|
-- Sanity checks generating warnings only, but not errors!
|
||||||
warnTermDays tid [sfVisibleFrom, Just sfActiveFrom, Just sfActiveTo, sfHintFrom, sfSolutionFrom]
|
warnTermDays tid $ Map.fromList [ (date,name) | (Just date, name) <-
|
||||||
|
[ (sfVisibleFrom, MsgSheetVisibleFrom)
|
||||||
|
, (Just sfActiveFrom, MsgSheetActiveFrom)
|
||||||
|
, (Just sfActiveTo, MsgSheetActiveTo)
|
||||||
|
, (sfHintFrom, MsgSheetSolutionFromTip)
|
||||||
|
, (sfSolutionFrom, MsgSheetSolutionFrom)
|
||||||
|
] ]
|
||||||
return True
|
return True
|
||||||
when saveOkay $ redirect $ case msId of
|
when saveOkay $ redirect $ case msId of
|
||||||
Just _ -> CSheetR tid ssh csh sfName SShowR -- redirect must happen outside of runDB
|
Just _ -> CSheetR tid ssh csh sfName SShowR -- redirect must happen outside of runDB
|
||||||
Nothing -> CSheetR tid ssh csh sfName SCorrR
|
Nothing -> CSheetR tid ssh csh sfName SCorrR
|
||||||
(FormFailure msgs) -> forM_ msgs $ (addMessage Error) . toHtml
|
(FormFailure msgs) -> forM_ msgs $ (addMessage Error) . toHtml
|
||||||
_ -> runDB $ warnTermDays tid $ (join . (flip fmap template))
|
_ -> runDB $ warnTermDays tid $ Map.fromList [ (date,name) | (Just date, name) <-
|
||||||
<$> [sfVisibleFrom, Just . sfActiveFrom, Just . sfActiveTo, sfHintFrom, sfSolutionFrom]
|
[(sfVisibleFrom =<< template, MsgSheetVisibleFrom)
|
||||||
|
,(sfActiveFrom <$> template, MsgSheetActiveFrom)
|
||||||
|
,(sfActiveTo <$> template, MsgSheetActiveTo)
|
||||||
|
,(sfHintFrom =<< template, MsgSheetSolutionFromTip)
|
||||||
|
,(sfSolutionFrom =<< template, MsgSheetSolutionFrom)
|
||||||
|
] ]
|
||||||
|
|
||||||
let pageTitle = maybe (MsgSheetTitleNew tid ssh csh)
|
let pageTitle = maybe (MsgSheetTitleNew tid ssh csh)
|
||||||
(MsgSheetTitle tid ssh csh) mbshn
|
(MsgSheetTitle tid ssh csh) mbshn
|
||||||
|
|||||||
@ -8,7 +8,8 @@ import Utils.Lens
|
|||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as T
|
import qualified Data.Text.Encoding as T
|
||||||
-- import qualified Data.Set (Set)
|
import Data.Map ((!))
|
||||||
|
import qualified Data.Map as Map
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Data.CaseInsensitive (original)
|
import Data.CaseInsensitive (original)
|
||||||
-- import qualified Data.CaseInsensitive as CI
|
-- import qualified Data.CaseInsensitive as CI
|
||||||
@ -199,15 +200,17 @@ prependCourseTitle tid ssh csh msg = UniWorXMessages
|
|||||||
colonText :: Text
|
colonText :: Text
|
||||||
colonText = ":"
|
colonText = ":"
|
||||||
|
|
||||||
warnTermDays :: TermId -> [Maybe UTCTime] -> DB ()
|
warnTermDays :: (RenderMessage UniWorX msg) => TermId -> Map UTCTime msg -> DB ()
|
||||||
warnTermDays tid times = do
|
warnTermDays tid timeNames = do
|
||||||
Term{..} <- get404 tid
|
Term{..} <- get404 tid
|
||||||
let alldays = Set.map utctDay $ Set.fromList $ catMaybes times
|
MsgRenderer mr <- getMsgRenderer
|
||||||
warnholidays = Set.intersection alldays $ Set.fromList termHolidays
|
let alldays = Map.keysSet timeNames
|
||||||
outoftermdays = Set.filter (\d -> d < termStart || d > termEnd ) alldays
|
warnholidays = let hdays = Set.fromList termHolidays in
|
||||||
outoflecture = Set.filter (\d -> d < termLectureStart || d > termLectureEnd) alldays
|
Set.filter (\(utctDay -> d) -> Set.member d hdays) alldays
|
||||||
|
outoftermdays = Set.filter (\(utctDay -> d) -> d < termStart || d > termEnd ) alldays
|
||||||
|
outoflecture = Set.filter (\(utctDay -> d) -> d < termLectureStart || d > termLectureEnd) alldays
|
||||||
`Set.difference` outoftermdays -- out of term implies out of lecture-time
|
`Set.difference` outoftermdays -- out of term implies out of lecture-time
|
||||||
warnI msg d = formatTime SelFormatDate d >>= \dt -> addMessageI Warning $ msg tid dt
|
warnI msg d = formatTime SelFormatDate d >>= \dt -> addMessageI Warning $ msg tid (mr (timeNames ! d)) dt
|
||||||
forM_ warnholidays $ warnI MsgDayIsAHoliday
|
forM_ warnholidays $ warnI MsgDayIsAHoliday
|
||||||
forM_ outoflecture $ warnI MsgDayIsOutOfLecture
|
forM_ outoflecture $ warnI MsgDayIsOutOfLecture
|
||||||
forM_ outoftermdays $ warnI MsgDayIsOutOfTerm
|
forM_ outoftermdays $ warnI MsgDayIsOutOfTerm
|
||||||
@ -250,7 +253,7 @@ guardAuthorizedFor :: ( HandlerSite h ~ UniWorX, MonadHandler h, MonadLogger h
|
|||||||
guardAuthorizedFor link val =
|
guardAuthorizedFor link val =
|
||||||
val <$ guardM (lift $ (== Authorized) <$> evalAccessDB link False)
|
val <$ guardM (lift $ (== Authorized) <$> evalAccessDB link False)
|
||||||
|
|
||||||
|
|
||||||
runAppLoggingT :: UniWorX -> LoggingT m a -> m a
|
runAppLoggingT :: UniWorX -> LoggingT m a -> m a
|
||||||
runAppLoggingT app@(appLogger -> (_, loggerTVar)) = flip runLoggingT logFunc
|
runAppLoggingT app@(appLogger -> (_, loggerTVar)) = flip runLoggingT logFunc
|
||||||
where
|
where
|
||||||
|
|||||||
@ -344,7 +344,7 @@ extractRatingsMsg = do
|
|||||||
(Right $(widgetFile "messages/submissionFilesIgnored"))
|
(Right $(widgetFile "messages/submissionFilesIgnored"))
|
||||||
addMessageWidget Warning ignoredModal
|
addMessageWidget Warning ignoredModal
|
||||||
|
|
||||||
-- Nicht innerhalb von runDB aufrufen, damit das DB Rollback passieren kann!
|
-- | Nicht innerhalb von runDB aufrufen, damit das DB Rollback passieren kann!
|
||||||
msgSubmissionErrors :: (MonadHandler m, MonadCatch m, HandlerSite m ~ UniWorX) => m a -> m (Maybe a)
|
msgSubmissionErrors :: (MonadHandler m, MonadCatch m, HandlerSite m ~ UniWorX) => m a -> m (Maybe a)
|
||||||
msgSubmissionErrors = flip catches
|
msgSubmissionErrors = flip catches
|
||||||
[ E.Handler $ \e -> Nothing <$ addMessageI Error (e :: RatingException)
|
[ E.Handler $ \e -> Nothing <$ addMessageI Error (e :: RatingException)
|
||||||
|
|||||||
@ -2,12 +2,14 @@ module Utils.Frontend.Modal
|
|||||||
( Modal(..)
|
( Modal(..)
|
||||||
, customModal
|
, customModal
|
||||||
, modal, msgModal
|
, modal, msgModal
|
||||||
|
, addMessageModal
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Utils.Route
|
import Utils.Route
|
||||||
|
import Utils.Message
|
||||||
|
|
||||||
import Settings (widgetFile)
|
import Settings (widgetFile)
|
||||||
|
|
||||||
@ -61,3 +63,12 @@ msgModal modalTrigger' modalContent = do
|
|||||||
customModal Modal{..}
|
customModal Modal{..}
|
||||||
where
|
where
|
||||||
modalTrigger mRoute triggerId = $(widgetFile "widgets/modal/trigger")
|
modalTrigger mRoute triggerId = $(widgetFile "widgets/modal/trigger")
|
||||||
|
|
||||||
|
-- | add message alert with a short trigger widget, whose larger content is displayed in a modal
|
||||||
|
addMessageModal :: forall m site.
|
||||||
|
( MonadHandler m
|
||||||
|
, HandlerSite m ~ site
|
||||||
|
, Yesod site
|
||||||
|
) => MessageStatus -> WidgetT site IO () -> Either (SomeRoute site) (WidgetT site IO ()) -> m ()
|
||||||
|
addMessageModal ms trigger content = addMessageWidget ms $ msgModal trigger content
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ module Utils.Message
|
|||||||
, messageI, messageIHamlet, messageFile, messageWidget
|
, messageI, messageIHamlet, messageFile, messageWidget
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
||||||
import Data.Universe
|
import Data.Universe
|
||||||
import Utils.PathPiece
|
import Utils.PathPiece
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
@ -110,6 +109,7 @@ addMessageWidget :: forall m site.
|
|||||||
, Yesod site
|
, Yesod site
|
||||||
) => MessageStatus -> WidgetT site IO () -> m ()
|
) => MessageStatus -> WidgetT site IO () -> m ()
|
||||||
-- ^ _Note_: `addMessageWidget` ignores `pageTitle` and `pageHead`
|
-- ^ _Note_: `addMessageWidget` ignores `pageTitle` and `pageHead`
|
||||||
|
-- also see Utils.Frontend.Modal.addMessageModal for large alerts with modal links
|
||||||
addMessageWidget mc wgt = do
|
addMessageWidget mc wgt = do
|
||||||
PageContent{pageBody} <- liftHandlerT $ widgetToPageContent wgt
|
PageContent{pageBody} <- liftHandlerT $ widgetToPageContent wgt
|
||||||
addMessageIHamlet mc (const pageBody :: HtmlUrlI18n (SomeMessage site) (Route site))
|
addMessageIHamlet mc (const pageBody :: HtmlUrlI18n (SomeMessage site) (Route site))
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
_{MsgCorrectionsUploaded (genericLength subs')}
|
_{MsgCorrectionsUploaded (genericLength subs')}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
$forall cID <- subs'
|
$forall (cID,uuid) <- subs'
|
||||||
<li>
|
<li>
|
||||||
#{toPathPiece cID}
|
^{simpleLink (toWidget (toPathPiece cID)) (CryptoUUIDDispatchR (ciphertext uuid))}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user