more licence stuff

This commit is contained in:
nek0 2016-12-19 00:40:21 +01:00
parent d27006b5c8
commit 14718c3c18

View file

@ -214,7 +214,13 @@ dUploadForm userId albumId = FileBulk
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
<*> pure albumId
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
where
licenses = optionsPairs $ I.map (\a -> (T.pack (show (toEnum a :: Licence)), a)) [-2..6]
defLicence = do
user <- runDB $ selectJust userId
return $ Just $ userDefaultLicence user
data FileBulk = FileBulk
@ -242,7 +248,7 @@ getUploadR = do
setMessage "Please create an album first"
redirect NewAlbumR
else do
(uploadWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId user
(uploadWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId
defaultLayout $ do
setTitle "Eidolon :: Upload Medium"
$(widgetFile "bulkUpload")
@ -251,7 +257,7 @@ getUploadR = do
redirect LoginR
bulkUploadForm :: UserId -> User -> AForm Handler FileBulk
bulkUploadForm userId user = (\a b c d e f g -> FileBulk b c d e f g a)
bulkUploadForm userId = (\a b c d e f g h -> FileBulk b c d e f g a h)
<$> areq (selectField albums) (bfs ("Album" :: T.Text)) Nothing
<*> areq textField (bfs ("Title" :: T.Text)) Nothing
<*> areq multiFileField "Select file(s)" Nothing
@ -259,7 +265,7 @@ bulkUploadForm userId user = (\a b c d e f g -> FileBulk b c d e f g a)
<*> pure userId
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
<*> areq (selectField licences) (bfs ("Licences" :: T.Text)) (Just $ userDefaultLicence user)
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
where
albums = do
@ -272,6 +278,9 @@ bulkUploadForm userId user = (\a b c d e f g -> FileBulk b c d e f g a)
) allEnts
optionsPairs $ I.map (\alb -> (albumTitle $ entityVal alb, entityKey alb)) entities
licenses = optionsPairs $ I.map (\a -> (T.pack (show (toEnum a :: Licence)), a)) [-2..6]
defLicence = do
user <- runDB $ selectJust userId
return $ Just $ userDefaultLicence user
postUploadR :: Handler Html
postUploadR = do
@ -279,8 +288,7 @@ postUploadR = do
case msu of
Just tempUserId -> do
let userId = getUserIdFromText tempUserId
user <- runDB $ getJust userId
((result, _), _) <- runFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId user
((result, _), _) <- runFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId
case result of
FormSuccess temp -> do
let fils = fileBulkFiles temp