Merge branch 'master' into 'live'

Deploy submission cleanup

See merge request !52
This commit is contained in:
Gregor Kleen 2018-07-10 13:57:13 +02:00
commit 3560b2ae5e
4 changed files with 15 additions and 13 deletions

4
routes
View File

@ -64,10 +64,10 @@
/subs SSubsR GET POST
/subs/new SubmissionNewR GET POST !timeANDregistered
/subs/own SubmissionOwnR GET !free -- just redirect
/sub/#CryptoFileNameSubmission SubmissionR !corrector:
/sub/#CryptoFileNameSubmission SubmissionR !correctorANDisRead:
/ SubShowR GET POST !ownerANDtime !ownerANDisRead
/archive/#{ZIPArchiveName SubmissionFileType} SubArchiveR GET !owner
/correction CorrectionR GET POST !ownerANDisRead
/correction CorrectionR GET POST !corrector !ownerANDisRead
!/#SubmissionFileType/*FilePath SubDownloadR GET !owner
/correctors SCorrR GET POST
!/#SheetFileType/*FilePath SFileR GET !timeANDregistered !timeANDmaterials !corrector

View File

@ -246,6 +246,8 @@ submissionHelper tid csh shn (SubmissionMode mcid) = do
Nothing -> return ()
actionUrl <- Data.Maybe.fromJust <$> getCurrentRoute
maySubmit <- (== Authorized) <$> isAuthorized actionUrl True
-- Maybe construct a table to display uploaded archive files
let colonnadeFiles :: _ -> Colonnade Sortable _ (DBCell (WidgetT UniWorX IO) ())
colonnadeFiles cid = mconcat
@ -355,7 +357,8 @@ getSubArchiveR tid csh shn cID@CryptoID{..} (ZIPArchiveName sfType) = do
fileSource' = do
fileSource .| Conduit.map entityVal
maybe (return ()) (yieldM . ratingFile cID) rating
when (sfType == SubmissionCorrected) $
maybe (return ()) (yieldM . ratingFile cID) rating
zipComment = Text.encodeUtf8 . pack $ CI.foldedCase ciphertext

View File

@ -285,15 +285,12 @@ instance Default Theme where
derivePersistField "Theme"
newtype ZIPArchiveName obj = ZIPArchiveName obj
newtype ZIPArchiveName obj = ZIPArchiveName { unZIPArchiveName :: obj }
deriving (Show, Read, Eq)
instance PathPiece obj => PathPiece (ZIPArchiveName obj) where
fromPathPiece (map CI.mk . unpack -> s)
| Just s' <- stripSuffix (map CI.mk ".zip") s = fromPathPiece . pack $ map CI.original s'
| otherwise = Nothing
toPathPiece (ZIPArchiveName obj) = toPathPiece obj <> ".zip"
fromPathPiece = fmap ZIPArchiveName . fromPathPiece <=< (stripSuffix `on` CI.foldCase) ".zip"
toPathPiece = (<> ".zip") . toPathPiece . unZIPArchiveName
newtype DateTimeFormat = DateTimeFormat { unDateTimeFormat :: String }
deriving (Eq, Ord, Read, Show, ToJSON, FromJSON, PersistField, PersistFieldSql)

View File

@ -1,7 +1,8 @@
$maybe cID <- mcid
<section style="padding-bottom:1em; margin-bottom:1em; border-bottom:1px solid black;">
<section>
<h2>
<a href=@{CSubmissionR tid csh shn cID (SubArchiveR (ZIPArchiveName SubmissionCorrected))}>Archiv
(<a href=@{CSubmissionR tid csh shn cID (SubArchiveR (ZIPArchiveName SubmissionOriginal))}>Original</a>)
$if not (null lastEdits)
<h3>_{MsgLastEdits}
<ul>
@ -11,6 +12,7 @@ $maybe cID <- mcid
<h3>_{MsgSubmissionFiles}
^{fileTable}
<section>
<form .form-horizontal method=post action=@{actionUrl} enctype=#{formEnctype}>
^{formWidget}
$if maySubmit
<section>
<form .form-horizontal method=post action=@{actionUrl} enctype=#{formEnctype}>
^{formWidget}