more licence stuff
This commit is contained in:
parent
d27006b5c8
commit
14718c3c18
1 changed files with 13 additions and 5 deletions
|
@ -214,7 +214,13 @@ dUploadForm userId albumId = FileBulk
|
||||||
<*> 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
|
||||||
<*> pure albumId
|
<*> pure albumId
|
||||||
|
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
||||||
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
<* 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
|
data FileBulk = FileBulk
|
||||||
|
@ -242,7 +248,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 user
|
(uploadWidget, enctype) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm userId
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Eidolon :: Upload Medium"
|
setTitle "Eidolon :: Upload Medium"
|
||||||
$(widgetFile "bulkUpload")
|
$(widgetFile "bulkUpload")
|
||||||
|
@ -251,7 +257,7 @@ getUploadR = do
|
||||||
redirect LoginR
|
redirect LoginR
|
||||||
|
|
||||||
bulkUploadForm :: UserId -> User -> AForm Handler FileBulk
|
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 (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
|
||||||
|
@ -259,7 +265,7 @@ bulkUploadForm userId user = (\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)
|
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
||||||
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
||||||
where
|
where
|
||||||
albums = do
|
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
|
) 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]
|
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 :: Handler Html
|
||||||
postUploadR = do
|
postUploadR = do
|
||||||
|
@ -279,8 +288,7 @@ postUploadR = do
|
||||||
case msu of
|
case msu of
|
||||||
Just tempUserId -> do
|
Just tempUserId -> do
|
||||||
let userId = getUserIdFromText tempUserId
|
let userId = getUserIdFromText tempUserId
|
||||||
user <- runDB $ getJust userId
|
((result, _), _) <- runFormPost $ renderBootstrap3 BootstrapBasicForm $ bulkUploadForm 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