continuing
This commit is contained in:
parent
63b1f4b27f
commit
d27006b5c8
1 changed files with 8 additions and 4 deletions
|
@ -225,6 +225,7 @@ data FileBulk = FileBulk
|
||||||
, fileBulkDesc :: Maybe Textarea
|
, fileBulkDesc :: Maybe Textarea
|
||||||
, fileBulkTags :: [T.Text]
|
, fileBulkTags :: [T.Text]
|
||||||
, fileBulkAlbum :: AlbumId
|
, fileBulkAlbum :: AlbumId
|
||||||
|
, fileBulkLicence :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
getUploadR :: Handler Html
|
getUploadR :: Handler Html
|
||||||
|
@ -241,7 +242,7 @@ getUploadR = do
|
||||||
setMessage "Please create an album first"
|
setMessage "Please create an album first"
|
||||||
redirect NewAlbumR
|
redirect NewAlbumR
|
||||||
else do
|
else do
|
||||||
(uploadWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId
|
(uploadWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId user
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Eidolon :: Upload Medium"
|
setTitle "Eidolon :: Upload Medium"
|
||||||
$(widgetFile "bulkUpload")
|
$(widgetFile "bulkUpload")
|
||||||
|
@ -249,8 +250,8 @@ getUploadR = do
|
||||||
setMessage "You need to be logged in"
|
setMessage "You need to be logged in"
|
||||||
redirect LoginR
|
redirect LoginR
|
||||||
|
|
||||||
bulkUploadForm :: UserId -> AForm Handler FileBulk
|
bulkUploadForm :: UserId -> User -> AForm Handler FileBulk
|
||||||
bulkUploadForm userId = (\a b c d e f g -> FileBulk b c d e f g a)
|
bulkUploadForm userId user = (\a b c d e f g -> FileBulk b c d e f g a)
|
||||||
<$> areq (selectField albums) (bfs ("Album" :: T.Text)) Nothing
|
<$> areq (selectField albums) (bfs ("Album" :: T.Text)) Nothing
|
||||||
<*> areq textField (bfs ("Title" :: T.Text)) Nothing
|
<*> areq textField (bfs ("Title" :: T.Text)) Nothing
|
||||||
<*> areq multiFileField "Select file(s)" Nothing
|
<*> areq multiFileField "Select file(s)" Nothing
|
||||||
|
@ -258,6 +259,7 @@ bulkUploadForm userId = (\a b c d e f g -> FileBulk b c d e f g a)
|
||||||
<*> pure userId
|
<*> pure userId
|
||||||
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
|
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
|
||||||
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
|
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
|
||||||
|
<*> areq (selectField licences) (bfs ("Licences" :: T.Text)) (Just $ userDefaultLicence user)
|
||||||
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
||||||
where
|
where
|
||||||
albums = do
|
albums = do
|
||||||
|
@ -269,6 +271,7 @@ bulkUploadForm userId = (\a b c d e f g -> FileBulk b c d e f g a)
|
||||||
else Nothing
|
else Nothing
|
||||||
) allEnts
|
) allEnts
|
||||||
optionsPairs $ I.map (\alb -> (albumTitle $ entityVal alb, entityKey alb)) entities
|
optionsPairs $ I.map (\alb -> (albumTitle $ entityVal alb, entityKey alb)) entities
|
||||||
|
licenses = optionsPairs $ I.map (\a -> (T.pack (show (toEnum a :: Licence)), a)) [-2..6]
|
||||||
|
|
||||||
postUploadR :: Handler Html
|
postUploadR :: Handler Html
|
||||||
postUploadR = do
|
postUploadR = do
|
||||||
|
@ -276,7 +279,8 @@ postUploadR = do
|
||||||
case msu of
|
case msu of
|
||||||
Just tempUserId -> do
|
Just tempUserId -> do
|
||||||
let userId = getUserIdFromText tempUserId
|
let userId = getUserIdFromText tempUserId
|
||||||
((result, _), _) <- runFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId
|
user <- runDB $ getJust userId
|
||||||
|
((result, _), _) <- runFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId user
|
||||||
case result of
|
case result of
|
||||||
FormSuccess temp -> do
|
FormSuccess temp -> do
|
||||||
let fils = fileBulkFiles temp
|
let fils = fileBulkFiles temp
|
||||||
|
|
Loading…
Reference in a new issue