diff --git a/messages/uniworx/de-de-formal.msg b/messages/uniworx/de-de-formal.msg index dc77097ae..5943d7e06 100644 --- a/messages/uniworx/de-de-formal.msg +++ b/messages/uniworx/de-de-formal.msg @@ -139,6 +139,7 @@ ScheduleOffsetWeekForwardWeek: 1 Woche vorwärts ScheduleOptActions: Terminübersicht ScheduleOptOut: Deabonnieren ScheduleOptIn: Abonnieren +ScheduleOptDelete: Standard wiederherstellen ScheduleOptOutSuccess: Termin erfolgreich deabonniert ScheduleOptInSuccess: Termin erfolgreich abonniert diff --git a/messages/uniworx/en-eu.msg b/messages/uniworx/en-eu.msg index 64ac06b63..fb4d434ee 100644 --- a/messages/uniworx/en-eu.msg +++ b/messages/uniworx/en-eu.msg @@ -140,6 +140,7 @@ ScheduleOffsetWeekForwardWeek: 1 week forward ScheduleOptActions: Schedule ScheduleOptOut: Unsubscribe ScheduleOptIn: Subscribe +ScheduleOptDelete: Reset to default ScheduleOptOutSuccess: Successfully unsubscribed from occurrence ScheduleOptInSuccess: Successfully subscribed to occurrence diff --git a/routes b/routes index ef4e8a0b5..8bac50418 100644 --- a/routes +++ b/routes @@ -216,10 +216,11 @@ !/download/*FilePath CNFileR GET !timeANDparticipant !/events/add CEventsNewR GET POST /events/#CryptoUUIDCourseEvent CourseEventR: - /schedule-opt/#Bool CEvScheduleOptR GET POST !free - /edit CEvEditR GET POST - /delete CEvDeleteR GET POST - /personalised-sheet-files CPersonalFilesR GET + /schedule-opt/set/#Bool CEvScheduleOptSetR GET POST !free + /schedule-opt/delete CEvScheduleOptDelR GET POST !free + /edit CEvEditR GET POST + /delete CEvDeleteR GET POST + /personalised-sheet-files CPersonalFilesR GET /subs CorrectionsR GET POST !corrector !lecturer diff --git a/src/Foundation/Navigation.hs b/src/Foundation/Navigation.hs index 6f9bbbaa4..9a8bd4a14 100644 --- a/src/Foundation/Navigation.hs +++ b/src/Foundation/Navigation.hs @@ -207,7 +207,8 @@ instance BearerAuthSite UniWorX => YesodBreadcrumbs UniWorX where breadcrumb (CourseR tid ssh csh CEventsNewR) = i18nCrumb MsgMenuCourseEventNew . Just $ CourseR tid ssh csh CShowR breadcrumb (CourseR tid ssh csh (CourseEventR _cID sRoute)) = case sRoute of - CEvScheduleOptR _ -> i18nCrumb MsgBreadcrumbCourseEventScheduleOpt . Just $ CourseR tid ssh csh CShowR + CEvScheduleOptSetR _ -> i18nCrumb MsgBreadcrumbCourseEventScheduleOpt . Just $ CourseR tid ssh csh CShowR + CEvScheduleOptDelR -> i18nCrumb MsgBreadcrumbCourseEventScheduleOpt . Just $ CourseR tid ssh csh CShowR CEvEditR -> i18nCrumb MsgMenuCourseEventEdit . Just $ CourseR tid ssh csh CShowR CEvDeleteR -> i18nCrumb MsgBreadcrumbCourseEventDelete . Just $ CourseR tid ssh csh CShowR diff --git a/src/Handler/Course/Events/Schedule.hs b/src/Handler/Course/Events/Schedule.hs index 42822b24a..a43977b38 100644 --- a/src/Handler/Course/Events/Schedule.hs +++ b/src/Handler/Course/Events/Schedule.hs @@ -1,13 +1,14 @@ module Handler.Course.Events.Schedule - ( getCEvScheduleOptR , postCEvScheduleOptR + ( getCEvScheduleOptSetR , postCEvScheduleOptSetR + , getCEvScheduleOptDelR , postCEvScheduleOptDelR ) where import Import -getCEvScheduleOptR, postCEvScheduleOptR :: TermId -> SchoolId -> CourseShorthand -> CryptoUUIDCourseEvent -> Bool -> Handler Html -getCEvScheduleOptR = postCEvScheduleOptR -postCEvScheduleOptR tid ssh csh ceId opt = do +getCEvScheduleOptSetR, postCEvScheduleOptSetR :: TermId -> SchoolId -> CourseShorthand -> CryptoUUIDCourseEvent -> Bool -> Handler Html +getCEvScheduleOptSetR = postCEvScheduleOptSetR +postCEvScheduleOptSetR tid ssh csh ceId opt = do uid <- requireAuthId eId <- decrypt ceId @@ -21,3 +22,15 @@ postCEvScheduleOptR tid ssh csh ceId opt = do addMessageI Success $ bool MsgScheduleOptOutSuccess MsgScheduleOptInSuccess opt redirect $ CourseR tid ssh csh CShowR + + +getCEvScheduleOptDelR, postCEvScheduleOptDelR :: TermId -> SchoolId -> CourseShorthand -> CryptoUUIDCourseEvent -> Handler Html +getCEvScheduleOptDelR = postCEvScheduleOptDelR +postCEvScheduleOptDelR tid ssh csh ceId = do + uid <- requireAuthId + eId <- decrypt ceId + + runDB $ deleteBy (UniqueCourseEventScheduleOpt eId uid) + + addMessageI Success MsgScheduleOptDeleteSuccess + redirect $ CourseR tid ssh csh CShowR diff --git a/templates/course.hamlet b/templates/course.hamlet index 2d452ddf8..5fc9403b3 100644 --- a/templates/course.hamlet +++ b/templates/course.hamlet @@ -285,9 +285,10 @@ $# $if NTop (Just 0) < NTop (courseCapacity course) $maybe (_, User{userScheduleOccurrenceDisplayDefault}) <- mbAuth
- + _{bool MsgScheduleOptIn MsgScheduleOptOut (maybe userScheduleOccurrenceDisplayDefault courseEventScheduleOptOpt mEventScheduleOpt)} - $# TODO: add link to remove schedule opt-* + + _{MsgScheduleOptDelete} $if mayCreateEvents