CreatedBy/ChangeBy als eigene Tabellen überall eingeführt
This commit is contained in:
parent
6fe311ee78
commit
05a0f6b0bf
35
fill-db.hs
35
fill-db.hs
@ -87,20 +87,17 @@ main = db $ do
|
|||||||
, courseTermId = TermKey summer2018
|
, courseTermId = TermKey summer2018
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 20
|
, courseCapacity = Just 20
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = gkleen
|
|
||||||
, courseChangedBy = gkleen
|
|
||||||
, courseHasRegistration = True
|
, courseHasRegistration = True
|
||||||
, courseRegisterFrom = Just now
|
, courseRegisterFrom = Just now
|
||||||
, courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now )
|
, courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now )
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit jost now ffp
|
||||||
void . insert $ DegreeCourse ifiBsc ffp
|
void . insert $ DegreeCourse ifiBsc ffp
|
||||||
void . insert $ DegreeCourse ifiMsc ffp
|
void . insert $ DegreeCourse ifiMsc ffp
|
||||||
void . insert $ Lecturer gkleen ffp
|
void . insert $ Lecturer gkleen ffp
|
||||||
insert_ $ Corrector gkleen ffp (ByProportion 1)
|
insert_ $ Corrector gkleen ffp (ByProportion 1)
|
||||||
sheetkey <- insert $ Sheet ffp "Blatt 1" Nothing NotGraded NoGroups Nothing Nothing now now Nothing Nothing
|
sheetkey <- insert $ Sheet ffp "Blatt 1" Nothing NotGraded NoGroups Nothing Nothing now now Nothing Nothing
|
||||||
insert_ $ SheetEdit gkleen sheetkey now
|
insert_ $ SheetEdit gkleen now sheetkey
|
||||||
-- EIP
|
-- EIP
|
||||||
eip <- insert Course
|
eip <- insert Course
|
||||||
{ courseName = "Einführung in die Programmierung"
|
{ courseName = "Einführung in die Programmierung"
|
||||||
@ -110,14 +107,11 @@ main = db $ do
|
|||||||
, courseTermId = TermKey summer2017
|
, courseTermId = TermKey summer2017
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 20
|
, courseCapacity = Just 20
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = fhamann
|
|
||||||
, courseChangedBy = fhamann
|
|
||||||
, courseHasRegistration = False
|
, courseHasRegistration = False
|
||||||
, courseRegisterFrom = Nothing
|
, courseRegisterFrom = Nothing
|
||||||
, courseRegisterTo = Nothing
|
, courseRegisterTo = Nothing
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit fhamann now eip
|
||||||
void . insert $ DegreeCourse ifiBsc eip
|
void . insert $ DegreeCourse ifiBsc eip
|
||||||
void . insert $ DegreeCourse ifiMsc eip
|
void . insert $ DegreeCourse ifiMsc eip
|
||||||
void . insert $ Lecturer fhamann eip
|
void . insert $ Lecturer fhamann eip
|
||||||
@ -130,14 +124,11 @@ main = db $ do
|
|||||||
, courseTermId = TermKey summer2018
|
, courseTermId = TermKey summer2018
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 20
|
, courseCapacity = Just 20
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = fhamann
|
|
||||||
, courseChangedBy = fhamann
|
|
||||||
, courseHasRegistration = True
|
, courseHasRegistration = True
|
||||||
, courseRegisterFrom = Just now
|
, courseRegisterFrom = Just now
|
||||||
, courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now )
|
, courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now )
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit fhamann now ixd
|
||||||
void . insert $ DegreeCourse ifiBsc ixd
|
void . insert $ DegreeCourse ifiBsc ixd
|
||||||
void . insert $ Lecturer fhamann ixd
|
void . insert $ Lecturer fhamann ixd
|
||||||
-- concept development
|
-- concept development
|
||||||
@ -149,14 +140,11 @@ main = db $ do
|
|||||||
, courseTermId = TermKey winter2017
|
, courseTermId = TermKey winter2017
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 30
|
, courseCapacity = Just 30
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = fhamann
|
|
||||||
, courseChangedBy = fhamann
|
|
||||||
, courseHasRegistration = False
|
, courseHasRegistration = False
|
||||||
, courseRegisterFrom = Nothing
|
, courseRegisterFrom = Nothing
|
||||||
, courseRegisterTo = Nothing
|
, courseRegisterTo = Nothing
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit fhamann now ux3
|
||||||
void . insert $ DegreeCourse ifiBsc ux3
|
void . insert $ DegreeCourse ifiBsc ux3
|
||||||
void . insert $ Lecturer fhamann ux3
|
void . insert $ Lecturer fhamann ux3
|
||||||
-- promo
|
-- promo
|
||||||
@ -168,14 +156,11 @@ main = db $ do
|
|||||||
, courseTermId = TermKey summer2017
|
, courseTermId = TermKey summer2017
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 50
|
, courseCapacity = Just 50
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = jost
|
|
||||||
, courseChangedBy = jost
|
|
||||||
, courseHasRegistration = False
|
, courseHasRegistration = False
|
||||||
, courseRegisterFrom = Nothing
|
, courseRegisterFrom = Nothing
|
||||||
, courseRegisterTo = Nothing
|
, courseRegisterTo = Nothing
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit jost now pmo
|
||||||
void . insert $ DegreeCourse ifiBsc pmo
|
void . insert $ DegreeCourse ifiBsc pmo
|
||||||
void . insert $ Lecturer jost pmo
|
void . insert $ Lecturer jost pmo
|
||||||
-- datenbanksysteme
|
-- datenbanksysteme
|
||||||
@ -187,13 +172,11 @@ main = db $ do
|
|||||||
, courseTermId = TermKey summer2018
|
, courseTermId = TermKey summer2018
|
||||||
, courseSchoolId = ifi
|
, courseSchoolId = ifi
|
||||||
, courseCapacity = Just 50
|
, courseCapacity = Just 50
|
||||||
, courseCreated = now
|
|
||||||
, courseChanged = now
|
|
||||||
, courseCreatedBy = jost
|
|
||||||
, courseChangedBy = jost
|
|
||||||
, courseHasRegistration = False
|
, courseHasRegistration = False
|
||||||
, courseRegisterFrom = Nothing
|
, courseRegisterFrom = Nothing
|
||||||
, courseRegisterTo = Nothing
|
, courseRegisterTo = Nothing
|
||||||
}
|
}
|
||||||
|
insert_ $ CourseEdit gkleen now dbs
|
||||||
void . insert $ DegreeCourse ifiBsc dbs
|
void . insert $ DegreeCourse ifiBsc dbs
|
||||||
void . insert $ Lecturer jost dbs
|
void . insert $ Lecturer gkleen dbs
|
||||||
|
void . insert $ Lecturer jost dbs
|
||||||
|
|||||||
43
models
43
models
@ -61,14 +61,14 @@ Course
|
|||||||
termId TermId
|
termId TermId
|
||||||
schoolId SchoolId
|
schoolId SchoolId
|
||||||
capacity Int Maybe
|
capacity Int Maybe
|
||||||
created UTCTime
|
|
||||||
changed UTCTime
|
|
||||||
createdBy UserId
|
|
||||||
changedBy UserId
|
|
||||||
hasRegistration Bool -- canRegisterNow = hasRegistration && maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo
|
hasRegistration Bool -- canRegisterNow = hasRegistration && maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo
|
||||||
registerFrom UTCTime Maybe
|
registerFrom UTCTime Maybe
|
||||||
registerTo UTCTime Maybe
|
registerTo UTCTime Maybe
|
||||||
CourseTermShort termId shorthand
|
CourseTermShort termId shorthand
|
||||||
|
CourseEdit
|
||||||
|
user UserId
|
||||||
|
time UTCTime
|
||||||
|
course CourseId
|
||||||
Lecturer
|
Lecturer
|
||||||
userId UserId
|
userId UserId
|
||||||
courseId CourseId
|
courseId CourseId
|
||||||
@ -106,8 +106,8 @@ Sheet
|
|||||||
CourseSheet courseId name
|
CourseSheet courseId name
|
||||||
SheetEdit
|
SheetEdit
|
||||||
user UserId
|
user UserId
|
||||||
sheet SheetId
|
|
||||||
time UTCTime
|
time UTCTime
|
||||||
|
sheet SheetId
|
||||||
SheetFile
|
SheetFile
|
||||||
sheetId SheetId
|
sheetId SheetId
|
||||||
fileId FileId
|
fileId FileId
|
||||||
@ -124,11 +124,11 @@ Submission
|
|||||||
ratingComment Text Maybe
|
ratingComment Text Maybe
|
||||||
ratingBy UserId Maybe
|
ratingBy UserId Maybe
|
||||||
ratingTime UTCTime Maybe
|
ratingTime UTCTime Maybe
|
||||||
created UTCTime
|
|
||||||
changed UTCTime
|
|
||||||
createdBy UserId
|
|
||||||
changedBy UserId
|
|
||||||
deriving Show
|
deriving Show
|
||||||
|
SubmissionEdit
|
||||||
|
user UserId
|
||||||
|
time UTCTime
|
||||||
|
submission SubmissionId
|
||||||
SubmissionFile
|
SubmissionFile
|
||||||
submissionId SubmissionId
|
submissionId SubmissionId
|
||||||
fileId FileId
|
fileId FileId
|
||||||
@ -143,10 +143,10 @@ SubmissionUser
|
|||||||
SubmissionGroup
|
SubmissionGroup
|
||||||
courseId CourseId
|
courseId CourseId
|
||||||
name Text
|
name Text
|
||||||
created UTCTime
|
SubmissionGroupEdit
|
||||||
changed UTCTime
|
user UserId
|
||||||
createdBy UserId
|
time UTCTime
|
||||||
changedBy UserId
|
submissionGroup SubmissionGroupId
|
||||||
SubmissionGroupUser
|
SubmissionGroupUser
|
||||||
submissionGroupId SubmissionGroupId
|
submissionGroupId SubmissionGroupId
|
||||||
userId UserId
|
userId UserId
|
||||||
@ -165,13 +165,12 @@ Booking
|
|||||||
end UTCTime
|
end UTCTime
|
||||||
weekly Bool
|
weekly Bool
|
||||||
exceptions [Day] -- only if weekly, begin in exception
|
exceptions [Day] -- only if weekly, begin in exception
|
||||||
created UTCTime
|
|
||||||
changed UTCTime
|
|
||||||
createdBy UserId
|
|
||||||
changedBy UserId
|
|
||||||
|
|
||||||
bookedFor RoomForId
|
bookedFor RoomForId
|
||||||
room RoomId
|
room RoomId
|
||||||
|
BookingEdit
|
||||||
|
user UserId
|
||||||
|
time UTCTime
|
||||||
|
boooking BookingId
|
||||||
Room
|
Room
|
||||||
name Text
|
name Text
|
||||||
capacity Int Maybe
|
capacity Int Maybe
|
||||||
@ -197,10 +196,10 @@ Exam
|
|||||||
deregistrationEnd UTCTime
|
deregistrationEnd UTCTime
|
||||||
ratingVisible Bool
|
ratingVisible Bool
|
||||||
statisticsVisible Bool
|
statisticsVisible Bool
|
||||||
created UTCTime
|
ExamEdit
|
||||||
changed UTCTime
|
user UserId
|
||||||
createdBy UserId
|
time UTCTime
|
||||||
changedBy UserId
|
exam ExamId
|
||||||
ExamUser
|
ExamUser
|
||||||
userId UserId
|
userId UserId
|
||||||
examId ExamId
|
examId ExamId
|
||||||
|
|||||||
@ -177,7 +177,7 @@ courseEditHandler course = do
|
|||||||
, cfTerm = tid
|
, cfTerm = tid
|
||||||
})) -> do -- create new course
|
})) -> do -- create new course
|
||||||
let tident = unTermKey tid
|
let tident = unTermKey tid
|
||||||
actTime <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
insertOkay <- runDB $ insertUnique $ Course
|
insertOkay <- runDB $ insertUnique $ Course
|
||||||
{ courseName = cfName res
|
{ courseName = cfName res
|
||||||
, courseDescription = cfDesc res
|
, courseDescription = cfDesc res
|
||||||
@ -189,14 +189,12 @@ courseEditHandler course = do
|
|||||||
, courseHasRegistration = cfHasReg res
|
, courseHasRegistration = cfHasReg res
|
||||||
, courseRegisterFrom = cfRegFrom res
|
, courseRegisterFrom = cfRegFrom res
|
||||||
, courseRegisterTo = cfRegTo res
|
, courseRegisterTo = cfRegTo res
|
||||||
, courseCreated = actTime
|
}
|
||||||
, courseChanged = actTime
|
|
||||||
, courseCreatedBy = aid
|
|
||||||
, courseChangedBy = aid
|
|
||||||
}
|
|
||||||
case insertOkay of
|
case insertOkay of
|
||||||
(Just cid) -> do
|
(Just cid) -> do
|
||||||
runDB $ insert_ $ Lecturer aid cid
|
runDB $ do
|
||||||
|
insert_ $ CourseEdit aid now cid
|
||||||
|
insert_ $ Lecturer aid cid
|
||||||
addMessageI "info" $ MsgCourseNewOk tident csh
|
addMessageI "info" $ MsgCourseNewOk tident csh
|
||||||
redirect $ CourseListTermR tid
|
redirect $ CourseListTermR tid
|
||||||
Nothing ->
|
Nothing ->
|
||||||
@ -208,7 +206,7 @@ courseEditHandler course = do
|
|||||||
, cfTerm = tid
|
, cfTerm = tid
|
||||||
})) -> do -- edit existing course
|
})) -> do -- edit existing course
|
||||||
let tident = unTermKey tid
|
let tident = unTermKey tid
|
||||||
actTime <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
-- addMessage "debug" [shamlet| #{show res}|]
|
-- addMessage "debug" [shamlet| #{show res}|]
|
||||||
runDB $ do
|
runDB $ do
|
||||||
old <- get cid
|
old <- get cid
|
||||||
@ -231,9 +229,9 @@ courseEditHandler course = do
|
|||||||
-- , CourseRegisterFrom =. cfRegFrom res
|
-- , CourseRegisterFrom =. cfRegFrom res
|
||||||
-- , CourseRegisterTo =. cfRegTo res
|
-- , CourseRegisterTo =. cfRegTo res
|
||||||
-- , CourseChangedBy =. aid
|
-- , CourseChangedBy =. aid
|
||||||
-- , CourseChanged =. actTime
|
-- , CourseChanged =. now
|
||||||
-- ]
|
-- ]
|
||||||
updOkay <- replace cid ( -- TODO replaceUnique requires Eq?!
|
_updOkay <- replace cid ( -- TODO replaceUnique requires Eq?!
|
||||||
Course { courseName = cfName res
|
Course { courseName = cfName res
|
||||||
, courseDescription = cfDesc res
|
, courseDescription = cfDesc res
|
||||||
, courseLinkExternal = cfLink res
|
, courseLinkExternal = cfLink res
|
||||||
@ -241,15 +239,12 @@ courseEditHandler course = do
|
|||||||
, courseTermId = cfTerm res
|
, courseTermId = cfTerm res
|
||||||
, courseSchoolId = cfSchool res
|
, courseSchoolId = cfSchool res
|
||||||
, courseCapacity = cfCapacity res
|
, courseCapacity = cfCapacity res
|
||||||
, courseChanged = actTime
|
|
||||||
, courseChangedBy = aid
|
|
||||||
, courseCreated = courseCreated oldCourse
|
|
||||||
, courseCreatedBy = courseCreatedBy oldCourse
|
|
||||||
, courseHasRegistration = cfHasReg res
|
, courseHasRegistration = cfHasReg res
|
||||||
, courseRegisterFrom = cfRegFrom res
|
, courseRegisterFrom = cfRegFrom res
|
||||||
, courseRegisterTo = cfRegTo res
|
, courseRegisterTo = cfRegTo res
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
insert_ $ CourseEdit aid now cid
|
||||||
-- if (isNothing updOkay)
|
-- if (isNothing updOkay)
|
||||||
-- then do
|
-- then do
|
||||||
addMessageI "info" $ MsgCourseEditOk tident csh
|
addMessageI "info" $ MsgCourseEditOk tident csh
|
||||||
|
|||||||
@ -317,7 +317,7 @@ handleSheetEdit tid csh template dbAction = do
|
|||||||
whenIsJust sfSheetF $ insertSheetFile sid SheetExercise
|
whenIsJust sfSheetF $ insertSheetFile sid SheetExercise
|
||||||
whenIsJust sfHintF $ insertSheetFile sid SheetHint
|
whenIsJust sfHintF $ insertSheetFile sid SheetHint
|
||||||
whenIsJust sfSolutionF $ insertSheetFile sid SheetSolution
|
whenIsJust sfSolutionF $ insertSheetFile sid SheetSolution
|
||||||
insert_ $ SheetEdit aid sid actTime
|
insert_ $ SheetEdit aid actTime sid
|
||||||
addMessageI "info" $ MsgSheetEditOk tident csh sfName
|
addMessageI "info" $ MsgSheetEditOk tident csh sfName
|
||||||
return True
|
return True
|
||||||
when saveOkay $ redirect $ CSheetR tid csh $ SheetShowR sfName -- redirect must happen outside of runDB
|
when saveOkay $ redirect $ CSheetR tid csh $ SheetShowR sfName -- redirect must happen outside of runDB
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
{-# LANGUAGE FlexibleContexts #-}
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE ViewPatterns #-}
|
||||||
|
|
||||||
module Handler.Submission where
|
module Handler.Submission where
|
||||||
|
|
||||||
@ -177,8 +178,12 @@ postSubmissionDownloadMultiArchiveR = do
|
|||||||
|
|
||||||
withinDirectory f@File{..} = f { fileTitle = directoryName </> fileTitle }
|
withinDirectory f@File{..} = f { fileTitle = directoryName </> fileTitle }
|
||||||
|
|
||||||
|
lastEditMb <- lift $ selectList [SubmissionEditSubmission ==. submissionID] [Desc SubmissionEditTime, LimitTo 1]
|
||||||
|
lastEditTime <- case lastEditMb of
|
||||||
|
[(submissionEditTime.entityVal -> time)] -> return time
|
||||||
|
_other -> liftIO getCurrentTime
|
||||||
yield $ File
|
yield $ File
|
||||||
{ fileModified = submissionChanged
|
{ fileModified = lastEditTime
|
||||||
, fileTitle = directoryName
|
, fileTitle = directoryName
|
||||||
, fileContent = Nothing
|
, fileContent = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,12 +70,9 @@ sinkSubmission sheetId userId mExists = do
|
|||||||
submissionRatingComment = Nothing
|
submissionRatingComment = Nothing
|
||||||
submissionRatingBy = Nothing
|
submissionRatingBy = Nothing
|
||||||
submissionRatingTime = Nothing
|
submissionRatingTime = Nothing
|
||||||
submissionCreated = now
|
|
||||||
submissionChanged = now
|
|
||||||
submissionCreatedBy = userId
|
|
||||||
submissionChangedBy = userId
|
|
||||||
|
|
||||||
(sId, isUpdate) <- lift $ maybe ((, False) <$> insert Submission{..}) return mExists
|
(sId, isUpdate) <- lift $ maybe ((, False) <$> (insert Submission{..} >>= (\sid -> sid <$ insert (SubmissionEdit userId now sid)))) return mExists
|
||||||
|
|
||||||
|
|
||||||
sId <$ sinkSubmission' sId isUpdate
|
sId <$ sinkSubmission' sId isUpdate
|
||||||
where
|
where
|
||||||
@ -184,9 +181,9 @@ sinkSubmission sheetId userId mExists = do
|
|||||||
alreadyTouched <- gets $ getAny . sinkSubmissionTouched
|
alreadyTouched <- gets $ getAny . sinkSubmissionTouched
|
||||||
when (not alreadyTouched) $ do
|
when (not alreadyTouched) $ do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
lift . update submissionId $ case isUpdate of
|
lift $ case isUpdate of
|
||||||
False -> [ SubmissionChangedBy =. userId, SubmissionChanged =. now ]
|
False -> insert_ $ SubmissionEdit userId now submissionId
|
||||||
True -> [ SubmissionRatingBy =. Just userId, SubmissionRatingTime =. Just now ]
|
True -> update submissionId [ SubmissionRatingBy =. Just userId, SubmissionRatingTime =. Just now ]
|
||||||
tell $ mempty{ sinkSubmissionTouched = Any True }
|
tell $ mempty{ sinkSubmissionTouched = Any True }
|
||||||
|
|
||||||
finalize :: SubmissionSinkState -> YesodDB UniWorX ()
|
finalize :: SubmissionSinkState -> YesodDB UniWorX ()
|
||||||
|
|||||||
Reference in New Issue
Block a user