53 lines
1.9 KiB
Haskell
53 lines
1.9 KiB
Haskell
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} -- ihamletFile discards do results
|
|
|
|
module Jobs.Handler.SendNotification.SheetInactive
|
|
( dispatchNotificationSheetSoonInactive
|
|
, dispatchNotificationSheetInactive
|
|
) where
|
|
|
|
import Import
|
|
|
|
import Handler.Utils.Mail
|
|
|
|
import Text.Hamlet
|
|
import qualified Data.CaseInsensitive as CI
|
|
|
|
dispatchNotificationSheetSoonInactive :: SheetId -> UserId -> Handler ()
|
|
dispatchNotificationSheetSoonInactive nSheet jRecipient = userMailT jRecipient $ do
|
|
(Course{..}, Sheet{..}) <- liftHandlerT . runDB $ do
|
|
sheet <- getJust nSheet
|
|
course <- belongsToJust sheetCourse sheet
|
|
return (course, sheet)
|
|
setSubjectI $ MsgMailSubjectSheetSoonInactive courseShorthand sheetName
|
|
|
|
MsgRenderer mr <- getMailMsgRenderer
|
|
let termDesc = mr . ShortTermIdentifier $ unTermKey courseTerm
|
|
tid = courseTerm
|
|
ssh = courseSchool
|
|
csh = courseShorthand
|
|
shn = sheetName
|
|
|
|
addAlternatives $ do
|
|
let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet")
|
|
providePreferredAlternative ($(ihamletFile "templates/mail/sheetSoonInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
|
|
|
|
dispatchNotificationSheetInactive :: SheetId -> UserId -> Handler ()
|
|
dispatchNotificationSheetInactive nSheet jRecipient = userMailT jRecipient $ do
|
|
(Course{..}, Sheet{..}) <- liftHandlerT . runDB $ do
|
|
sheet <- getJust nSheet
|
|
course <- belongsToJust sheetCourse sheet
|
|
return (course, sheet)
|
|
setSubjectI $ MsgMailSubjectSheetInactive courseShorthand sheetName
|
|
|
|
MsgRenderer mr <- getMailMsgRenderer
|
|
let termDesc = mr . ShortTermIdentifier $ unTermKey courseTerm
|
|
tid = courseTerm
|
|
ssh = courseSchool
|
|
csh = courseShorthand
|
|
shn = sheetName
|
|
|
|
addAlternatives $ do
|
|
let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet")
|
|
providePreferredAlternative ($(ihamletFile "templates/mail/sheetInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
|
|
|