diff --git a/models/submissions.model b/models/submissions.model index e8ea0d049..c29e0373f 100644 --- a/models/submissions.model +++ b/models/submissions.model @@ -23,12 +23,9 @@ SubmissionUser -- which submission belongs to whom UniqueSubmissionUser user submission -- multiple users may share same submission, in case of (ad-hoc) submission groups SubmissionGroup -- pre-defined submission groups; some courses only allow pre-defined submission groups course CourseId - name Text Maybe -SubmissionGroupEdit -- who edited a submissionGroup when? - user UserId - time UTCTime - submissionGroup SubmissionGroupId + name SubmissionGroupName + UniqueSubmissionGroup course name SubmissionGroupUser -- Registered submission groups, just for checking upon submission, but independent of actual SubmissionUser submissionGroup SubmissionGroupId user UserId - UniqueSubmissionGroupUser submissionGroup user + UniqueSubmissionGroupUser submissionGroup user diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index 2b605d3db..e10aadab4 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -592,18 +592,11 @@ mkSubmissionGroupTable = , course E.^. CourseSchool , course E.^. CourseShorthand ) - return (crse, sgroup, lastSGEdit sgroup) + return (crse, sgroup) dbtRowKey (_ `E.InnerJoin` sgroup `E.InnerJoin` _) = sgroup E.^. SubmissionGroupId - lastSGEdit sgroup = -- latest Edit-Time of this Submission Group by a user - E.subSelectMaybe . E.from $ \(user `E.InnerJoin` sgEdit) -> do - E.on $ user E.^. UserId E.==. sgEdit E.^. SubmissionGroupEditUser - E.where_ $ sgEdit E.^. SubmissionGroupEditSubmissionGroup E.==. sgroup E.^. SubmissionGroupId - return . E.max_ $ sgEdit E.^. SubmissionGroupEditTime - dbtProj x = return $ x - & _dbrOutput . _1 %~ (\(E.Value tid, E.Value ssh, E.Value csh) -> (tid,ssh,csh)) - & _dbrOutput . _3 %~ E.unValue + & _dbrOutput . _1 %~ $(E.unValueN 3) dbtColonnade = mconcat [ sortable (Just "term") (i18nCell MsgTerm) $ @@ -614,21 +607,15 @@ mkSubmissionGroupTable = , sortable (Just "course") (i18nCell MsgCourse) $ courseCellCL <$> view (_dbrOutput . _1) , sortable (Just "submissiongroup") (i18nCell MsgSubmissionGroupName) . magnify (_dbrOutput . _2 . _entityVal) $ - maybe mempty textCell <$> view _submissionGroupName - , sortable (Just "edit") (i18nCell MsgLastEdit) $ - maybe mempty dateTimeCell <$> view (_dbrOutput . _3) + cell . views _submissionGroupName toWidget ] - validator = def -- DUPLICATED CODE: Handler.Corrections - & restrictFilter (\name _ -> name /= "corrector") -- We need to be careful to restrict allowed sorting/filter to not expose sensitive information - & restrictSorting (\name _ -> name /= "corrector") - & defaultSorting [SortDescBy "edit"] + validator = def & defaultSorting [SortDescBy "term", SortAscBy "school", SortAscBy "course"] dbtSorting = Map.fromList [ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ ) -> crse E.^. CourseShorthand) , ( "term" , SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ ) -> crse E.^. CourseTerm ) , ( "school", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ ) -> crse E.^. CourseSchool ) , ( "submissiongroup" , SortColumn $ withType $ \(_ `E.InnerJoin` sgroup `E.InnerJoin` _) -> sgroup E.^. SubmissionGroupName ) - , ( "edit" , SortColumn $ withType $ \(_ `E.InnerJoin` sgroup `E.InnerJoin` _ ) -> lastSGEdit sgroup) ] dbtFilter = Map.fromList [ ( "course", FilterColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _) -> emptyOrIn $ crse E.^. CourseShorthand) diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs index 85aca846e..547fd3580 100644 --- a/src/Model/Migration.hs +++ b/src/Model/Migration.hs @@ -632,6 +632,13 @@ customMigrations = Map.fromListWith (>>) , whenM (tableExists "allocation_matching") $ tableDropEmpty "allocation_matching" ) + , ( AppliedMigrationKey [migrationVersion|34.0.0|] [version|35.0.0|] + , do + whenM (tableExists "submission_group") $ + tableDropEmpty "submission_group" + whenM (tableExists "submission_group_edit") $ + tableDropEmpty "submission_group_edit" + ) ] diff --git a/src/Model/Types/Common.hs b/src/Model/Types/Common.hs index 54d6d5b00..692b939b7 100644 --- a/src/Model/Types/Common.hs +++ b/src/Model/Types/Common.hs @@ -47,6 +47,8 @@ type ExamOccurrenceName = CI Text type AllocationName = CI Text type AllocationShorthand = CI Text +type SubmissionGroupName = CI Text + type PWHashAlgorithm = ByteString -> PWStore.Salt -> Int -> ByteString type InstanceId = UUID type ClusterId = UUID