From 028cc3586d76fed5ab6195fcbcc07abedd86cdbc Mon Sep 17 00:00:00 2001 From: SJost Date: Wed, 24 Oct 2018 18:19:16 +0200 Subject: [PATCH] Profile cleaned --- ChangeLog.md | 2 + messages/uniworx/de.msg | 2 +- src/Foundation.hs | 4 +- src/Handler/Profile.hs | 75 +++++++++---------- .../SendNotification/CorrectionsAssigned.hs | 7 +- .../Handler/SendNotification/SheetActive.hs | 1 + .../Handler/SendNotification/SheetInactive.hs | 2 + .../SendNotification/SubmissionRated.hs | 1 + templates/mail/correctionsAssigned.hamlet | 1 + templates/mail/editNotifications.hamlet | 4 + templates/mail/sheetActive.hamlet | 1 + templates/mail/sheetInactive.hamlet | 1 + templates/mail/sheetSoonInactive.hamlet | 1 + templates/mail/submissionRated.hamlet | 1 + templates/profile.hamlet | 60 --------------- templates/profileData.hamlet | 71 ++++++++++++++++-- 16 files changed, 124 insertions(+), 110 deletions(-) create mode 100644 templates/mail/editNotifications.hamlet diff --git a/ChangeLog.md b/ChangeLog.md index ad60db498..e5e39dee3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,8 @@ Hilfe Widget + Benachrichtigungen per eMail für einige Ereignisse + * Version 18.09.2018 Tooltips funktionieren auch ohne JavaScript diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 89d0338fe..898b4385a 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -348,7 +348,7 @@ MailSheetSoonInactiveIntro courseName@Text termDesc@Text sheetName@SheetName: Ab MailSubjectSheetInactive csh@CourseShorthand sheetName@SheetName: Abgabfristt für #{sheetName} in #{csh} abgelaufen MailSheetInactiveIntro courseName@Text termDesc@Text sheetName@SheetName: Die Abgabefirst für #{sheetName} im Kurs #{courseName} (#{termDesc}) beendet. MailCorrectionsAssignedIntro courseName@Text termDesc@Text sheetName@SheetName n@Int: #{display n} Abgaben wurden Ihnen zur Korrektur für #{sheetName} im Kurs #{courseName} (#{termDesc}) zugeteilt. - +MailEditNotifications: Benachrichtigungen ein-/ausschalten MailSubjectSupport: Supportanfrage SheetTypeBonus: Bonus diff --git a/src/Foundation.hs b/src/Foundation.hs index 56f319f81..fe478f1ca 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -882,7 +882,7 @@ defaultLinks = -- Define the menu items of the header. , menuItemAccessCallback' = return True } , NavbarRight $ MenuItem - { menuItemLabel = "Profil" + { menuItemLabel = "Einstellungen" , menuItemIcon = Just "cogs" , menuItemRoute = ProfileR , menuItemModal = False @@ -966,7 +966,7 @@ pageActions (HomeR) = ] pageActions (ProfileR) = [ PageActionPrime $ MenuItem - { menuItemLabel = "Gespeicherte Daten anzeigen" + { menuItemLabel = "Gespeicherte Daten" , menuItemIcon = Just "book" , menuItemRoute = ProfileDataR , menuItemModal = False diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index 43f0702a9..86e03d26e 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -115,47 +115,11 @@ postProfileR = do (FormFailure msgs) -> forM_ msgs $ (addMessage Warning) . toHtml _ -> return () - - (admin_rights,lecturer_rights,lecture_corrector,studies) <- runDB $ (,,,) <$> - (E.select $ E.from $ \(adright `E.InnerJoin` school) -> do - E.where_ $ adright E.^. UserAdminUser E.==. E.val uid - E.on $ adright E.^. UserAdminSchool E.==. school E.^. SchoolId - return (school E.^. SchoolShorthand) - ) - <*> - (E.select $ E.from $ \(lecright `E.InnerJoin` school) -> do - E.where_ $ lecright E.^. UserLecturerUser E.==. E.val uid - E.on $ lecright E.^. UserLecturerSchool E.==. school E.^. SchoolId - return (school E.^. SchoolShorthand) - ) - <*> - (E.select $ E.distinct $ E.from $ \(sheet `E.InnerJoin` corrector `E.InnerJoin` course) -> do - E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId - E.on $ sheet E.^. SheetId E.==. corrector E.^. SheetCorrectorSheet - E.where_ $ corrector E.^. SheetCorrectorUser E.==. E.val uid - return (course E.^. CourseTerm, course E.^. CourseSchool, course E.^. CourseShorthand) - ) - <*> - (E.select $ E.from $ \(studydegree `E.InnerJoin` studyfeat `E.InnerJoin` studyterms) -> do - E.where_ $ studyfeat E.^. StudyFeaturesUser E.==. E.val uid - E.on $ studyfeat E.^. StudyFeaturesField E.==. studyterms E.^. StudyTermsId - E.on $ studyfeat E.^. StudyFeaturesDegree E.==. studydegree E.^. StudyDegreeId - return ( ( studydegree E.^. StudyDegreeName - , studydegree E.^. StudyDegreeKey - ) - , ( studyterms E.^. StudyTermsName - , studyterms E.^. StudyTermsKey - ) - , studyfeat E.^. StudyFeaturesType - , studyfeat E.^. StudyFeaturesSemester) - ) - let formText = Just MsgSettings - actionUrl = ProfileR - settingsForm = $(widgetFile "formPageI18n") + let formText = Nothing :: Maybe UniWorXMessage + actionUrl = ProfileR defaultLayout $ do setTitle . toHtml $ userIdent <> "'s User page" - $(widgetFile "profile") - $(widgetFile "dsgvDisclaimer") + $(widgetFile "formPageI18n") postProfileDataR :: Handler Html postProfileDataR = do @@ -233,6 +197,39 @@ getProfileDataR :: Handler Html getProfileDataR = do (uid, User{..}) <- requireAuthPair -- mr <- getMessageRender + (admin_rights,lecturer_rights,lecture_corrector,studies) <- runDB $ (,,,) <$> + (E.select $ E.from $ \(adright `E.InnerJoin` school) -> do + E.where_ $ adright E.^. UserAdminUser E.==. E.val uid + E.on $ adright E.^. UserAdminSchool E.==. school E.^. SchoolId + return (school E.^. SchoolShorthand) + ) + <*> + (E.select $ E.from $ \(lecright `E.InnerJoin` school) -> do + E.where_ $ lecright E.^. UserLecturerUser E.==. E.val uid + E.on $ lecright E.^. UserLecturerSchool E.==. school E.^. SchoolId + return (school E.^. SchoolShorthand) + ) + <*> + (E.select $ E.distinct $ E.from $ \(sheet `E.InnerJoin` corrector `E.InnerJoin` course) -> do + E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId + E.on $ sheet E.^. SheetId E.==. corrector E.^. SheetCorrectorSheet + E.where_ $ corrector E.^. SheetCorrectorUser E.==. E.val uid + return (course E.^. CourseTerm, course E.^. CourseSchool, course E.^. CourseShorthand) + ) + <*> + (E.select $ E.from $ \(studydegree `E.InnerJoin` studyfeat `E.InnerJoin` studyterms) -> do + E.where_ $ studyfeat E.^. StudyFeaturesUser E.==. E.val uid + E.on $ studyfeat E.^. StudyFeaturesField E.==. studyterms E.^. StudyTermsId + E.on $ studyfeat E.^. StudyFeaturesDegree E.==. studydegree E.^. StudyDegreeId + return ( ( studydegree E.^. StudyDegreeName + , studydegree E.^. StudyDegreeKey + ) + , ( studyterms E.^. StudyTermsName + , studyterms E.^. StudyTermsKey + ) + , studyfeat E.^. StudyFeaturesType + , studyfeat E.^. StudyFeaturesSemester) + ) -- Tabelle mit eigenen Kursen (hasRows, ownedCoursesTable) <- mkOwnedCoursesTable uid -- Tabelle mit allen Teilnehmer: Kurs (link), Datum diff --git a/src/Jobs/Handler/SendNotification/CorrectionsAssigned.hs b/src/Jobs/Handler/SendNotification/CorrectionsAssigned.hs index 71376d4ba..6b7ed47d8 100644 --- a/src/Jobs/Handler/SendNotification/CorrectionsAssigned.hs +++ b/src/Jobs/Handler/SendNotification/CorrectionsAssigned.hs @@ -22,8 +22,8 @@ dispatchNotificationCorrectionsAssigned nUser nSheet jRecipient = do (Course{..}, Sheet{..}, nbrSubs) <- liftHandlerT . runDB $ do sheet <- getJust nSheet course <- belongsToJust sheetCourse sheet - nbrSubs <- count [ SubmissionSheet ==. nSheet - , SubmissionRatingBy ==. Just nUser + nbrSubs <- count [ SubmissionSheet ==. nSheet + , SubmissionRatingBy ==. Just nUser , SubmissionRatingTime ==. Nothing ] return (course, sheet, nbrSubs) @@ -38,4 +38,5 @@ dispatchNotificationCorrectionsAssigned nUser nSheet jRecipient = do shn = sheetName addAlternatives $ do - providePreferredAlternative ($(ihamletFile "templates/mail/correctionsAssigned.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) + let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet") + providePreferredAlternative ($(ihamletFile "templates/mail/correctionsAssigned.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) diff --git a/src/Jobs/Handler/SendNotification/SheetActive.hs b/src/Jobs/Handler/SendNotification/SheetActive.hs index c25962a7e..aaedcb7a6 100644 --- a/src/Jobs/Handler/SendNotification/SheetActive.hs +++ b/src/Jobs/Handler/SendNotification/SheetActive.hs @@ -33,4 +33,5 @@ dispatchNotificationSheetActive nSheet jRecipient = userMailT jRecipient $ do shn = sheetName addAlternatives $ do + let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet") providePreferredAlternative ($(ihamletFile "templates/mail/sheetActive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) diff --git a/src/Jobs/Handler/SendNotification/SheetInactive.hs b/src/Jobs/Handler/SendNotification/SheetInactive.hs index 16f865167..6873d2b28 100644 --- a/src/Jobs/Handler/SendNotification/SheetInactive.hs +++ b/src/Jobs/Handler/SendNotification/SheetInactive.hs @@ -34,6 +34,7 @@ dispatchNotificationSheetSoonInactive nSheet jRecipient = userMailT jRecipient $ 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 () @@ -52,5 +53,6 @@ dispatchNotificationSheetInactive nSheet jRecipient = userMailT jRecipient $ do shn = sheetName addAlternatives $ do + let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet") providePreferredAlternative ($(ihamletFile "templates/mail/sheetInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) \ No newline at end of file diff --git a/src/Jobs/Handler/SendNotification/SubmissionRated.hs b/src/Jobs/Handler/SendNotification/SubmissionRated.hs index 91d983265..885dc8bfe 100644 --- a/src/Jobs/Handler/SendNotification/SubmissionRated.hs +++ b/src/Jobs/Handler/SendNotification/SubmissionRated.hs @@ -55,4 +55,5 @@ dispatchNotificationSubmissionRated nSubmission jRecipient = userMailT jRecipien , "course-school" Aeson..= courseSchool ] -- provideAlternative $ \(MsgRenderer mr) -> ($(textFile "templates/mail/submissionRated.txt") :: TextUrl (Route UniWorX)) -- textFile does not support control statements + let editNotifications = $(ihamletFile "templates/mail/editNotifications.hamlet") providePreferredAlternative ($(ihamletFile "templates/mail/submissionRated.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX)) diff --git a/templates/mail/correctionsAssigned.hamlet b/templates/mail/correctionsAssigned.hamlet index 1fda94c92..1f1b9c9e5 100644 --- a/templates/mail/correctionsAssigned.hamlet +++ b/templates/mail/correctionsAssigned.hamlet @@ -15,3 +15,4 @@ $newline never

_{MsgCorrectionsTitle} + ^{editNotifications} \ No newline at end of file diff --git a/templates/mail/editNotifications.hamlet b/templates/mail/editNotifications.hamlet new file mode 100644 index 000000000..7ca5d9f8b --- /dev/null +++ b/templates/mail/editNotifications.hamlet @@ -0,0 +1,4 @@ +

+ + _{MsgProfileHeading} + \ _{MsgMailEditNotifications} \ No newline at end of file diff --git a/templates/mail/sheetActive.hamlet b/templates/mail/sheetActive.hamlet index aecc4c458..330914bc4 100644 --- a/templates/mail/sheetActive.hamlet +++ b/templates/mail/sheetActive.hamlet @@ -15,3 +15,4 @@ $newline never

#{sheetName} + ^{editNotifications} \ No newline at end of file diff --git a/templates/mail/sheetInactive.hamlet b/templates/mail/sheetInactive.hamlet index 3b0664eb5..756736f42 100644 --- a/templates/mail/sheetInactive.hamlet +++ b/templates/mail/sheetInactive.hamlet @@ -15,3 +15,4 @@ $newline never

#{sheetName} + ^{editNotifications} \ No newline at end of file diff --git a/templates/mail/sheetSoonInactive.hamlet b/templates/mail/sheetSoonInactive.hamlet index a198fd65c..fb27ad1ed 100644 --- a/templates/mail/sheetSoonInactive.hamlet +++ b/templates/mail/sheetSoonInactive.hamlet @@ -15,3 +15,4 @@ $newline never

#{sheetName} + ^{editNotifications} \ No newline at end of file diff --git a/templates/mail/submissionRated.hamlet b/templates/mail/submissionRated.hamlet index 8e016dc0b..d808e4927 100644 --- a/templates/mail/submissionRated.hamlet +++ b/templates/mail/submissionRated.hamlet @@ -63,3 +63,4 @@ $newline never _{MsgRatingComment}

#{comment} + ^{editNotifications} diff --git a/templates/profile.hamlet b/templates/profile.hamlet index 45510425a..fc6a9bef7 100644 --- a/templates/profile.hamlet +++ b/templates/profile.hamlet @@ -1,62 +1,2 @@
- -
-
_{MsgName} -
^{nameWidget userDisplayName userSurname} - $maybe matnr <- userMatrikelnummer -
_{MsgMatrikelNr} -
#{matnr} -
_{MsgEMail} -
#{display userEmail} -
_{MsgIdent} -
#{display userIdent} - $if not $ null admin_rights -
Administrator -
-