fix(schools): perform authorship statement inserts

This commit is contained in:
Sarah Vaupel 2021-06-02 07:53:11 +02:00 committed by Gregor Kleen
parent 960bd76aca
commit 579371cffd

View File

@ -137,13 +137,11 @@ postSchoolEditR ssh = do
((sfResult, sfView), sfEnctype) <- runFormPost sForm
-- TODO: validate Form: when AuthorshipStatement required, the statement text must be `Just t` with `t` non-empty
formResult sfResult $ \SchoolForm{..} -> do
runDB $ do
let
mAuthorshipStatementId = error "WIP upsert authorship statement"
mExamAuthorshipStatementId = error "WIP upsert exam authorship statement"
let insertAuthorshipStatement = maybe (pure Nothing) $ fmap Just . insert . AuthorshipStatementDefinition
mSheetAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
mSheetExamAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
update ssh
[ SchoolName =. sfName
, SchoolExamMinimumRegisterBeforeStart =. sfExamMinimumRegisterBeforeStart
@ -152,10 +150,10 @@ postSchoolEditR ssh = do
, SchoolExamDiscouragedModes =. sfExamDiscouragedModes
, SchoolExamCloseMode =. sfExamCloseMode
, SchoolSheetAuthorshipStatementMode =. sfSheetAuthorshipStatementMode
, SchoolSheetAuthorshipStatementDefinition =. mAuthorshipStatementId
, SchoolSheetAuthorshipStatementDefinition =. mSheetAuthorshipStatementId
, SchoolSheetAuthorshipStatementAllowOther =. sfSheetAuthorshipStatementAllowOther
, SchoolSheetExamAuthorshipStatementMode =. sfSheetExamAuthorshipStatementMode
, SchoolSheetExamAuthorshipStatementDefinition =. mExamAuthorshipStatementId
, SchoolSheetExamAuthorshipStatementDefinition =. mSheetExamAuthorshipStatementId
, SchoolSheetExamAuthorshipStatementAllowOther =. sfSheetExamAuthorshipStatementAllowOther
]
forM_ sfOrgUnits $ \schoolLdapOrgUnit ->
@ -191,9 +189,9 @@ postSchoolNewR = do
formResult sfResult $ \SchoolForm{..} -> do
let ssh = SchoolKey sfShorthand
insertOkay <- runDB $ do
let
mAuthorshipStatementId = error "WIP insert authorship statement"
mExamAuthorshipStatementId = error "WIP insert exam authorship statement"
let insertAuthorshipStatement = maybe (pure Nothing) $ fmap Just . insert . AuthorshipStatementDefinition
mSheetAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
mSheetExamAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
didInsert <- is _Just <$> insertUnique School
{ schoolShorthand = sfShorthand
, schoolName = sfName
@ -203,10 +201,10 @@ postSchoolNewR = do
, schoolExamDiscouragedModes = sfExamDiscouragedModes
, schoolExamCloseMode = sfExamCloseMode
, schoolSheetAuthorshipStatementMode = sfSheetAuthorshipStatementMode
, schoolSheetAuthorshipStatementDefinition = mAuthorshipStatementId
, schoolSheetAuthorshipStatementDefinition = mSheetAuthorshipStatementId
, schoolSheetAuthorshipStatementAllowOther = sfSheetAuthorshipStatementAllowOther
, schoolSheetExamAuthorshipStatementMode = sfSheetExamAuthorshipStatementMode
, schoolSheetExamAuthorshipStatementDefinition = mExamAuthorshipStatementId
, schoolSheetExamAuthorshipStatementDefinition = mSheetExamAuthorshipStatementId
, schoolSheetExamAuthorshipStatementAllowOther = sfSheetExamAuthorshipStatementAllowOther
}
when didInsert $ do