From af2970735961763354aaf927fdf8c6f9112d578d Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 3 May 2019 09:02:41 +0200 Subject: [PATCH] workaround: no get method for course registration --- messages/uniworx/de.msg | 2 ++ routes | 2 +- src/Handler/Course.hs | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 4b8c7f201..75c9609d5 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -24,6 +24,7 @@ RegisteredSince date@Text: Angemeldet seit #{date} RegisterFrom: Anmeldungen von RegisterTo: Anmeldungen bis DeRegUntil: Abmeldungen bis +RegisterRetry: Sie wurden noch nicht angemeldet. Drücken Sie dazu den Knopf "Anmelden" GenericKey: Schlüssel GenericShort: Kürzel @@ -454,6 +455,7 @@ LDAPLoginTitle: Campus-Login PWHashLoginTitle: Uni2work-Login PWHashLoginNote: Dieses Formular ist zu verwenden, wenn Sie vom Uni2work-Team spezielle Logindaten erhalten haben. Normale Nutzer melden sich bitte via Campus-Login an! DummyLoginTitle: Development-Login +LoginNecessary: Bitte melden Sie sich dazu vorher an! CorrectorNormal: Normal CorrectorMissing: Abwesend diff --git a/routes b/routes index dd82ed43b..d77ccbf04 100644 --- a/routes +++ b/routes @@ -78,7 +78,7 @@ !/course/new CourseNewR GET POST !lecturer /course/#TermId/#SchoolId/#CourseShorthand CourseR !lecturer: / CShowR GET !free - /register CRegisterR POST !timeANDcapacity + /register CRegisterR GET POST !timeANDcapacity /edit CEditR GET POST /lecturer-invite/#UserEmail CLecInviteR GET POST /delete CDeleteR GET POST !lecturerANDempty diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index 339349e73..13da90fbf 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -390,7 +390,7 @@ getCShowR tid ssh csh = do tutorialDBTableValidator = def & defaultSorting [SortAscBy "type", SortAscBy "name"] (Any hasTutorials, tutorialTable) <- runDB $ dbTable tutorialDBTableValidator tutorialDBTable - + siteLayout (toWgt $ courseName course) $ do setTitleI $ prependCourseTitle tid ssh csh (""::Text) $(widgetFile "course") @@ -429,6 +429,19 @@ registerForm loggedin participant defSFid msecret = identifyForm FIDcourseRegist isRegistered = isJust participant +-- | Workaround for klicking register button without being logged in. +-- After log in, the user sees a "get request not supported" error. +getCRegisterR :: TermId -> SchoolId -> CourseShorthand -> Handler Html +getCRegisterR tid ssh csh = do + muid <- maybeAuthId + case muid of + Nothing -> addMessageI Info MsgLoginNecessary + (Just uid) -> runDB $ do + cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh + registration <- getBy (UniqueParticipant uid cid) + when (isNothing registration) $ addMessageI Warning MsgRegisterRetry + redirect $ CourseR tid ssh csh CShowR + postCRegisterR :: TermId -> SchoolId -> CourseShorthand -> Handler Html postCRegisterR tid ssh csh = do aid <- requireAuthId @@ -1122,7 +1135,7 @@ postTUsersR tid ssh csh tutn = do ] addMessageI Success $ MsgTutorialUsersDeregistered nrDel redirect $ CTutorialR tid ssh csh tutn TUsersR - + let heading = prependCourseTitle tid ssh csh $ CI.original tutorialName siteLayoutMsg heading $ do setTitleI heading