Course Capacity is verified now, in CRegister Handler that also checks secret
This commit is contained in:
parent
d8ad0f67a5
commit
9fc50e8736
@ -26,6 +26,7 @@ TermPlaceholder: W/S + vierstellige Jahreszahl
|
|||||||
LectureStart: Beginn Vorlesungen
|
LectureStart: Beginn Vorlesungen
|
||||||
|
|
||||||
Course: Kurs
|
Course: Kurs
|
||||||
|
CourseNoCapacity: In diesem Kurs sind keine Plätze mehr frei.
|
||||||
CourseSecret: Zugangspasswort
|
CourseSecret: Zugangspasswort
|
||||||
CourseNewOk tid@TermId courseShortHand@Text: Kurs #{display tid}-#{courseShortHand} wurde erfolgreich erstellt.
|
CourseNewOk tid@TermId courseShortHand@Text: Kurs #{display tid}-#{courseShortHand} wurde erfolgreich erstellt.
|
||||||
CourseEditOk tid@TermId courseShortHand@Text: Kurs #{display tid}-#{courseShortHand} wurde erfolgreich geändert.
|
CourseEditOk tid@TermId courseShortHand@Text: Kurs #{display tid}-#{courseShortHand} wurde erfolgreich geändert.
|
||||||
|
|||||||
@ -127,7 +127,14 @@ postCRegisterR tid csh = do
|
|||||||
addMessage "info" "Sie wurden abgemeldet."
|
addMessage "info" "Sie wurden abgemeldet."
|
||||||
| codeOk -> do
|
| codeOk -> do
|
||||||
actTime <- liftIO $ getCurrentTime
|
actTime <- liftIO $ getCurrentTime
|
||||||
regOk <- runDB $ insertUnique $ CourseParticipant cid aid actTime
|
regOk <- runDB $ do
|
||||||
|
reg <- count [CourseParticipantCourse ==. cid]
|
||||||
|
if NTop (Just reg) < NTop (courseCapacity course)
|
||||||
|
then -- current capacity has room
|
||||||
|
insertUnique $ CourseParticipant cid aid actTime
|
||||||
|
else do -- no space left
|
||||||
|
addMessageI "danger" MsgCourseNoCapacity
|
||||||
|
return Nothing
|
||||||
when (isJust regOk) $ addMessage "success" "Erfolgreich angemeldet!"
|
when (isJust regOk) $ addMessage "success" "Erfolgreich angemeldet!"
|
||||||
| otherwise -> addMessage "danger" "Falsches Kennwort!"
|
| otherwise -> addMessage "danger" "Falsches Kennwort!"
|
||||||
(_other) -> return () -- TODO check this!
|
(_other) -> return () -- TODO check this!
|
||||||
|
|||||||
@ -39,8 +39,8 @@ getUsersR = do
|
|||||||
cID <- encrypt $ entityKey $ fst3 u
|
cID <- encrypt $ entityKey $ fst3 u
|
||||||
let name = display $ userDisplayName $ entityVal $ fst3 u
|
let name = display $ userDisplayName $ entityVal $ fst3 u
|
||||||
[whamlet|<a href=@{AdminUserR cID}>#{name}|]
|
[whamlet|<a href=@{AdminUserR cID}>#{name}|]
|
||||||
, headed "Admin for Schools" $ (\u -> text2widget $ intercalate ", " $ map (getSchoolname.userAdminSchool .entityVal) $ snd3 u)
|
, headed "Admin" $ (\u -> text2widget $ intercalate ", " $ map (getSchoolname.userAdminSchool .entityVal) $ snd3 u)
|
||||||
, headed "Lecturer at Schools" $ (\u -> text2widget $ intercalate ", " $ map (getSchoolname.userLecturerSchool.entityVal) $ trd3 u)
|
, headed "Lecturer" $ (\u -> text2widget $ intercalate ", " $ map (getSchoolname.userLecturerSchool.entityVal) $ trd3 u)
|
||||||
]
|
]
|
||||||
-- ++ map (\school -> headed (text2widget $ schoolName $ entityVal school) (\u -> "xx")) schools
|
-- ++ map (\school -> headed (text2widget $ schoolName $ entityVal school) (\u -> "xx")) schools
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
|
|||||||
Reference in New Issue
Block a user