chore(lms): prevent resending and pin renewal for closed lms
This commit is contained in:
parent
78231b8dd1
commit
c76dc47890
@ -680,7 +680,11 @@ postLmsR sid qsh = do
|
||||
|
||||
(action, selectedUsers) | isRenewPinAct action || isNotifyAct action -> do
|
||||
numExaminees <- runDBJobs $ do
|
||||
okUsers <- selectList [LmsUserUser <-. Set.toList selectedUsers, LmsUserQualification ==. qid] []
|
||||
okUsers <- selectList [ LmsUserQualification ==. qid -- matching qualification
|
||||
, LmsUserEnded ==. Nothing -- not yet deleted
|
||||
, LmsUserStatus ==. Nothing -- not yet decided
|
||||
, LmsUserUser <-. Set.toList selectedUsers -- selected
|
||||
] []
|
||||
forM_ okUsers $ \(Entity lid LmsUser {lmsUserUser = uid, lmsUserQualification = qid'}) -> do
|
||||
when (isRenewPinAct action) $ do
|
||||
newPin <- liftIO randomLMSpw
|
||||
@ -690,8 +694,9 @@ postLmsR sid qsh = do
|
||||
return $ length okUsers
|
||||
let numSelected = length selectedUsers
|
||||
diffSelected = numSelected - numExaminees
|
||||
when (isRenewPinAct action) $ addMessageI Success $ MsgLmsPinRenewal numExaminees
|
||||
when (isNotifyAct action) $ addMessageI Success $ MsgLmsNotificationSend numExaminees
|
||||
mstat = bool Success Warning $ diffSelected /= 0
|
||||
when (isRenewPinAct action) $ addMessageI mstat $ MsgLmsPinRenewal numExaminees
|
||||
when (isNotifyAct action) $ addMessageI mstat $ MsgLmsNotificationSend numExaminees
|
||||
when (diffSelected /= 0) $ addMessageI Warning $ MsgLmsActionFailed diffSelected
|
||||
reloadKeepGetParams $ LmsR sid qsh
|
||||
_ -> addMessageI Error MsgUnauthorized -- should not happen
|
||||
|
||||
Loading…
Reference in New Issue
Block a user