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 ((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 formResult sfResult $ \SchoolForm{..} -> do
runDB $ do runDB $ do
let let insertAuthorshipStatement = maybe (pure Nothing) $ fmap Just . insert . AuthorshipStatementDefinition
mAuthorshipStatementId = error "WIP upsert authorship statement" mSheetAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
mExamAuthorshipStatementId = error "WIP upsert exam authorship statement" mSheetExamAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
update ssh update ssh
[ SchoolName =. sfName [ SchoolName =. sfName
, SchoolExamMinimumRegisterBeforeStart =. sfExamMinimumRegisterBeforeStart , SchoolExamMinimumRegisterBeforeStart =. sfExamMinimumRegisterBeforeStart
@ -152,10 +150,10 @@ postSchoolEditR ssh = do
, SchoolExamDiscouragedModes =. sfExamDiscouragedModes , SchoolExamDiscouragedModes =. sfExamDiscouragedModes
, SchoolExamCloseMode =. sfExamCloseMode , SchoolExamCloseMode =. sfExamCloseMode
, SchoolSheetAuthorshipStatementMode =. sfSheetAuthorshipStatementMode , SchoolSheetAuthorshipStatementMode =. sfSheetAuthorshipStatementMode
, SchoolSheetAuthorshipStatementDefinition =. mAuthorshipStatementId , SchoolSheetAuthorshipStatementDefinition =. mSheetAuthorshipStatementId
, SchoolSheetAuthorshipStatementAllowOther =. sfSheetAuthorshipStatementAllowOther , SchoolSheetAuthorshipStatementAllowOther =. sfSheetAuthorshipStatementAllowOther
, SchoolSheetExamAuthorshipStatementMode =. sfSheetExamAuthorshipStatementMode , SchoolSheetExamAuthorshipStatementMode =. sfSheetExamAuthorshipStatementMode
, SchoolSheetExamAuthorshipStatementDefinition =. mExamAuthorshipStatementId , SchoolSheetExamAuthorshipStatementDefinition =. mSheetExamAuthorshipStatementId
, SchoolSheetExamAuthorshipStatementAllowOther =. sfSheetExamAuthorshipStatementAllowOther , SchoolSheetExamAuthorshipStatementAllowOther =. sfSheetExamAuthorshipStatementAllowOther
] ]
forM_ sfOrgUnits $ \schoolLdapOrgUnit -> forM_ sfOrgUnits $ \schoolLdapOrgUnit ->
@ -191,9 +189,9 @@ postSchoolNewR = do
formResult sfResult $ \SchoolForm{..} -> do formResult sfResult $ \SchoolForm{..} -> do
let ssh = SchoolKey sfShorthand let ssh = SchoolKey sfShorthand
insertOkay <- runDB $ do insertOkay <- runDB $ do
let let insertAuthorshipStatement = maybe (pure Nothing) $ fmap Just . insert . AuthorshipStatementDefinition
mAuthorshipStatementId = error "WIP insert authorship statement" mSheetAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
mExamAuthorshipStatementId = error "WIP insert exam authorship statement" mSheetExamAuthorshipStatementId <- insertAuthorshipStatement sfSheetExamAuthorshipStatementDefinition
didInsert <- is _Just <$> insertUnique School didInsert <- is _Just <$> insertUnique School
{ schoolShorthand = sfShorthand { schoolShorthand = sfShorthand
, schoolName = sfName , schoolName = sfName
@ -203,10 +201,10 @@ postSchoolNewR = do
, schoolExamDiscouragedModes = sfExamDiscouragedModes , schoolExamDiscouragedModes = sfExamDiscouragedModes
, schoolExamCloseMode = sfExamCloseMode , schoolExamCloseMode = sfExamCloseMode
, schoolSheetAuthorshipStatementMode = sfSheetAuthorshipStatementMode , schoolSheetAuthorshipStatementMode = sfSheetAuthorshipStatementMode
, schoolSheetAuthorshipStatementDefinition = mAuthorshipStatementId , schoolSheetAuthorshipStatementDefinition = mSheetAuthorshipStatementId
, schoolSheetAuthorshipStatementAllowOther = sfSheetAuthorshipStatementAllowOther , schoolSheetAuthorshipStatementAllowOther = sfSheetAuthorshipStatementAllowOther
, schoolSheetExamAuthorshipStatementMode = sfSheetExamAuthorshipStatementMode , schoolSheetExamAuthorshipStatementMode = sfSheetExamAuthorshipStatementMode
, schoolSheetExamAuthorshipStatementDefinition = mExamAuthorshipStatementId , schoolSheetExamAuthorshipStatementDefinition = mSheetExamAuthorshipStatementId
, schoolSheetExamAuthorshipStatementAllowOther = sfSheetExamAuthorshipStatementAllowOther , schoolSheetExamAuthorshipStatementAllowOther = sfSheetExamAuthorshipStatementAllowOther
} }
when didInsert $ do when didInsert $ do