{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} -- ihamletFile discards do results module Jobs.Handler.SendNotification.ExamActive ( dispatchNotificationExamRegistrationActive , dispatchNotificationExamRegistrationSoonInactive , dispatchNotificationExamDeregistrationSoonInactive ) where import Import import Handler.Utils.Mail import Jobs.Handler.SendNotification.Utils import Text.Hamlet import qualified Data.CaseInsensitive as CI dispatchNotificationExamRegistrationActive :: ExamId -> UserId -> Handler () dispatchNotificationExamRegistrationActive nExam jRecipient = userMailT jRecipient $ do (Course{..}, Exam{..}) <- liftHandler . runDB $ do exam <- getJust nExam course <- belongsToJust examCourse exam return (course, exam) replaceMailHeader "Auto-Submitted" $ Just "auto-generated" setSubjectI $ MsgMailSubjectExamRegistrationActive courseShorthand examName MsgRenderer mr <- getMailMsgRenderer let termDesc = mr . ShortTermIdentifier $ unTermKey courseTerm tid = courseTerm ssh = courseSchool csh = courseShorthand examn = examName editNotifications <- mkEditNotifications jRecipient addAlternatives $ providePreferredAlternative ($(ihamletFile "templates/mail/examRegistrationActive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) dispatchNotificationExamRegistrationSoonInactive :: ExamId -> UserId -> Handler () dispatchNotificationExamRegistrationSoonInactive nExam jRecipient = userMailT jRecipient $ do (Course{..}, Exam{..}) <- liftHandler . runDB $ do exam <- getJust nExam course <- belongsToJust examCourse exam return (course, exam) replaceMailHeader "Auto-Submitted" $ Just "auto-generated" setSubjectI $ MsgMailSubjectExamRegistrationSoonInactive courseShorthand examName MsgRenderer mr <- getMailMsgRenderer let termDesc = mr . ShortTermIdentifier $ unTermKey courseTerm tid = courseTerm ssh = courseSchool csh = courseShorthand examn = examName editNotifications <- mkEditNotifications jRecipient addAlternatives $ providePreferredAlternative ($(ihamletFile "templates/mail/examRegistrationSoonInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) dispatchNotificationExamDeregistrationSoonInactive :: ExamId -> UserId -> Handler () dispatchNotificationExamDeregistrationSoonInactive nExam jRecipient = userMailT jRecipient $ do (Course{..}, Exam{..}) <- liftHandler . runDB $ do exam <- getJust nExam course <- belongsToJust examCourse exam return (course, exam) replaceMailHeader "Auto-Submitted" $ Just "auto-generated" setSubjectI $ MsgMailSubjectExamDeregistrationSoonInactive courseShorthand examName MsgRenderer mr <- getMailMsgRenderer let termDesc = mr . ShortTermIdentifier $ unTermKey courseTerm tid = courseTerm ssh = courseSchool csh = courseShorthand examn = examName editNotifications <- mkEditNotifications jRecipient addAlternatives $ providePreferredAlternative ($(ihamletFile "templates/mail/examDeregistrationSoonInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))