chore(add-users): fix tutorial audits
This commit is contained in:
parent
d195daadfc
commit
db3d1b0f70
@ -261,7 +261,8 @@ registerUser cid (_avsIdent, Just uid) = exceptT return return $ do
|
|||||||
upsertNewTutorial :: CourseId -> TutorialIdent -> Handler TutorialId
|
upsertNewTutorial :: CourseId -> TutorialIdent -> Handler TutorialId
|
||||||
upsertNewTutorial cid tutorialName = do
|
upsertNewTutorial cid tutorialName = do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
Entity tutId _ <- runDB $ upsert
|
tutId <- runDB $ do
|
||||||
|
Entity tutId _ <- upsert
|
||||||
Tutorial
|
Tutorial
|
||||||
{ tutorialCourse = cid
|
{ tutorialCourse = cid
|
||||||
, tutorialType = CI.mk "Schulung"
|
, tutorialType = CI.mk "Schulung"
|
||||||
@ -283,13 +284,15 @@ upsertNewTutorial cid tutorialName = do
|
|||||||
]
|
]
|
||||||
audit $ TransactionTutorialEdit tutId
|
audit $ TransactionTutorialEdit tutId
|
||||||
return tutId
|
return tutId
|
||||||
|
return tutId
|
||||||
|
|
||||||
registerTutorialMembers :: TutorialId -> Set UserId -> Handler ()
|
registerTutorialMembers :: TutorialId -> Set UserId -> Handler ()
|
||||||
registerTutorialMembers tutId (Set.toList -> users) = runDB $ do
|
registerTutorialMembers tutId (Set.toList -> users) = runDB $ do
|
||||||
prevParticipants <- fmap Set.fromList $ selectList [TutorialParticipantUser <-. users, TutorialParticipantTutorial ==. tutId] []
|
prevParticipants <- fmap (Set.fromList . fmap entityKey) $ selectList [TutorialParticipantUser <-. users, TutorialParticipantTutorial ==. tutId] []
|
||||||
participants <- fmap Set.fromList . for users $ \tutorialParticipantUser -> do
|
participants <- fmap Set.fromList . for users $ \tutorialParticipantUser -> do
|
||||||
tutPartId <- upsert TutorialParticipant { tutorialParticipantTutorial = tutId, .. } []
|
Entity tutPartId _ <- upsert TutorialParticipant { tutorialParticipantTutorial = tutId, .. } []
|
||||||
audit $ TransactionTutorialParticipantEdit tutId tutPartId tutorialParticipantUser
|
audit $ TransactionTutorialParticipantEdit tutId tutPartId tutorialParticipantUser
|
||||||
|
return tutPartId
|
||||||
let newParticipants = participants Set.\\ prevParticipants
|
let newParticipants = participants Set.\\ prevParticipants
|
||||||
unless (Set.null newParticipants) $
|
unless (Set.null newParticipants) $
|
||||||
addMessageI Success . MsgCourseParticipantsRegisteredTutorial $ Set.size newParticipants
|
addMessageI Success . MsgCourseParticipantsRegisteredTutorial $ Set.size newParticipants
|
||||||
|
|||||||
Reference in New Issue
Block a user