fix(submission-create): sanity check submittors in form
This commit is contained in:
parent
e5608d2d5b
commit
3bf37a4c1a
@ -264,7 +264,16 @@ makeSubmissionForm cid msmid uploadMode grouping isLecturer prefillUsers = ident
|
|||||||
miButtonAction = miButtonAction' mRoute
|
miButtonAction = miButtonAction' mRoute
|
||||||
|
|
||||||
postProcess :: Map ListPosition (Either UserEmail UserId, ()) -> Set (Either UserEmail UserId)
|
postProcess :: Map ListPosition (Either UserEmail UserId, ()) -> Set (Either UserEmail UserId)
|
||||||
postProcess = setOf $ folded . _1
|
postProcess valMap
|
||||||
|
| Just maxSize' <- maxSize
|
||||||
|
, fromIntegral maxSize' >= Set.size resultUsers
|
||||||
|
= resultUsers
|
||||||
|
| Just maxSize' <- maxSize
|
||||||
|
= let resultUsers' = Set.take (fromIntegral maxSize') resultUsers
|
||||||
|
in if | Set.member (Right uid) resultUsers' -> resultUsers'
|
||||||
|
| otherwise -> Set.insert (Right uid) $ Set.take (pred $ fromIntegral maxSize') resultUsers'
|
||||||
|
| otherwise = Set.singleton $ Right uid
|
||||||
|
where resultUsers = setOf (folded . _1) valMap
|
||||||
when (maxSize > Just 1) $
|
when (maxSize > Just 1) $
|
||||||
wformMessage =<< messageI Info MsgCosubmittorTip
|
wformMessage =<< messageI Info MsgCosubmittorTip
|
||||||
fmap postProcess <$> massInputW MassInput{..} submittorSettings' True (Just . Map.fromList . zip [0..] . map (, ()) $ Set.toList prefillUsers)
|
fmap postProcess <$> massInputW MassInput{..} submittorSettings' True (Just . Map.fromList . zip [0..] . map (, ()) $ Set.toList prefillUsers)
|
||||||
|
|||||||
Reference in New Issue
Block a user