Fix hlint

This commit is contained in:
Gregor Kleen 2019-05-04 18:25:06 +02:00
parent 4d7d3f43a5
commit 95298f856e
4 changed files with 15 additions and 16 deletions

View File

@ -48,10 +48,10 @@ makeMaterialForm cid template = identifyForm FIDmaterial $ \html -> do
previouslyUsed <- liftHandlerT . runDB $
E.select $ E.from $ \material ->
E.distinctOnOrderBy [E.asc $ material E.^. MaterialType] $ do
E.where_ $ (material E.^. MaterialCourse E.==. E.val cid)
E.&&. (E.not_ $ E.isNothing $ material E.^. MaterialType)
E.where_ $ material E.^. MaterialCourse E.==. E.val cid
E.&&. E.not_ (E.isNothing $ material E.^. MaterialType)
return $ material E.^. MaterialType
return $ defaults <> (Set.fromList $ mapMaybe E.unValue previouslyUsed)
return $ defaults <> Set.fromList (mapMaybe E.unValue previouslyUsed)
ctime <- ceilingQuarterHour <$> liftIO getCurrentTime
flip (renderAForm FormStandard) html $ MaterialForm
@ -88,7 +88,7 @@ getMaterialListR tid ssh csh = do
cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
let row2material = entityVal . dbrOutput -- no inner join, just Entity Material
psValidator = def & defaultSorting [SortDescBy "last-edit"]
table <- dbTableWidget' psValidator DBTable
dbTableWidget' psValidator DBTable
{ dbtIdent = "material-list" :: Text
, dbtStyle = def
, dbtParams = def
@ -120,10 +120,9 @@ getMaterialListR tid ssh csh = do
, dbtFilter = mempty
, dbtFilterUI = mempty
}
return table
let headingLong = prependCourseTitle tid ssh csh $ MsgMaterialListHeading
headingShort = prependCourseTitle tid ssh csh $ MsgMaterialListHeading
let headingLong = prependCourseTitle tid ssh csh MsgMaterialListHeading
headingShort = prependCourseTitle tid ssh csh MsgMaterialListHeading
siteLayoutMsg headingLong $ do
setTitleI headingShort
$(widgetFile "material-list")
@ -152,7 +151,7 @@ getMShowR :: TermId -> SchoolId -> CourseShorthand -> MaterialName -> Handler Ht
getMShowR tid ssh csh mnm = do
let matLink :: FilePath -> Route UniWorX
matLink = CourseR tid ssh csh . MaterialR mnm . MFileR
( (Entity _mid material@Material{materialType, materialDescription})
( Entity _mid material@Material{materialType, materialDescription}
, (Any hasFiles,fileTable)) <- runDB $ do
matEnt <- fetchMaterial tid ssh csh mnm
let psValidator = def & defaultSortingByFileTitle
@ -182,7 +181,7 @@ getMShowR tid ssh csh mnm = do
return (matEnt,fileTable')
let matVisFro = materialVisibleFrom material
now <- liftIO $ getCurrentTime
now <- liftIO getCurrentTime
materialLastEdit <- formatTime SelFormatDateTime $ materialLastEdit material
materialVisibleFrom <- traverse (formatTime SelFormatDateTime) matVisFro
when (NTop matVisFro >= NTop (Just now)) $ addMessageI Warning $
@ -206,7 +205,7 @@ postMEditR tid ssh csh mnm = do
return $ file E.^. FileId
return (matEnt, (Left . E.unValue) <$> fileIds)
-- let cid = materialCourse
let template = Just $ MaterialForm
let template = Just MaterialForm
{ mfName = materialName
, mfType = materialType
, mfDescription = materialDescription
@ -274,7 +273,7 @@ handleMaterialEdit tid ssh csh cid template dbMaterial = do
return $ file E.^. FileId
let oldFileIds = setFromList $ map E.unValue oldFileIdVals
keep <- execWriterT . runConduit $ transPipe (lift . lift) fs =$= C.mapM_ finsert
mapM_ deleteCascade $ (oldFileIds \\ keep :: Set FileId)
mapM_ deleteCascade (oldFileIds \\ keep :: Set FileId)
where
finsert (Left fileId) = tell $ singleton fileId
finsert (Right file) = lift $ do
@ -299,4 +298,4 @@ postMDelR tid ssh csh mnm = do
, drSuccess = SomeRoute $ CourseR tid ssh csh MaterialListR
, drAbort = SomeRoute $ CourseR tid ssh csh $ MaterialR mnm MShowR
}
-}
-}

View File

@ -52,7 +52,7 @@ serveOneFile :: DB [Entity File] -> Handler TypedContent
serveOneFile query = do
results <- runDB query
case results of
[(Entity _fileId File{fileTitle, fileContent})]
[Entity _fileId File{fileTitle, fileContent}]
| Just fileContent' <- fileContent -> do
whenM downloadFiles $
addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|]

View File

@ -203,5 +203,5 @@ ceilingMinuteBy margin roundto utct = addUTCTime bonus utct
oldTime = localTimeOfDay $ utcToLocalTime utct
oldMin = todMin oldTime
newMin = roundToNearestMultiple roundto $ oldMin + margin
newTime = oldTime { todMin = newMin, todSec = 0} -- might be invalid, but correctly treated by `timeOfDayToTime`
bonus = realToFrac $ (timeOfDayToTime newTime) - (timeOfDayToTime oldTime)
newTime = oldTime { todMin = newMin, todSec = 0 } -- might be invalid, but correctly treated by `timeOfDayToTime`
bonus = realToFrac $ timeOfDayToTime newTime - timeOfDayToTime oldTime

View File

@ -55,7 +55,7 @@ sqlCell act = mempty & cellContents .~ lift act
markCell :: (IsDBTable m a) => (a -> Bool) -> (a -> DBCell m a) -> a -> DBCell m a
markCell condition normal x
| condition x = (normal x) <> (cell $ isVisibleWidget False)
| condition x = normal x <> cell (isVisibleWidget False)
| otherwise = normal x