still changing logic
This commit is contained in:
parent
fd57460df1
commit
6cf9bebeed
2 changed files with 12 additions and 9 deletions
|
@ -13,6 +13,7 @@ data TempMedium = TempMedium
|
||||||
, tempMediumOwner :: UserId
|
, tempMediumOwner :: UserId
|
||||||
, tempMediumDesc :: Textarea
|
, tempMediumDesc :: Textarea
|
||||||
, tempMediumTags :: [Text]
|
, tempMediumTags :: [Text]
|
||||||
|
, tempMediumAlbum :: AlbumId
|
||||||
}
|
}
|
||||||
|
|
||||||
getUploadR :: Handler Html
|
getUploadR :: Handler Html
|
||||||
|
@ -49,11 +50,12 @@ postUploadR = do
|
||||||
(tempMediumOwner temp)
|
(tempMediumOwner temp)
|
||||||
(tempMediumDesc temp)
|
(tempMediumDesc temp)
|
||||||
(tempMediumTags temp)
|
(tempMediumTags temp)
|
||||||
mId <- runDB $ insert medium
|
(tempMediumAlbum temp)
|
||||||
setMessage $ [shamlet|Image succesfully uploaded|]
|
mId <- runDB $ I.insert medium
|
||||||
|
setMessage $ [shamlet|<pre>Image succesfully uploaded|]
|
||||||
redirect $ HomeR
|
redirect $ HomeR
|
||||||
_ -> do
|
_ -> do
|
||||||
setMessage $ [shamlet|There was an error uploading the file|]
|
setMessage $ [shamlet|<pre>There was an error uploading the file|]
|
||||||
redirect $ UploadR
|
redirect $ UploadR
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
setMessage $ [shamlet|<pre>You need to be logged in|]
|
setMessage $ [shamlet|<pre>You need to be logged in|]
|
||||||
|
@ -74,11 +76,12 @@ uploadForm userId = renderDivs $ TempMedium
|
||||||
<*> pure userId
|
<*> pure userId
|
||||||
<*> areq textareaField "Description" Nothing
|
<*> areq textareaField "Description" Nothing
|
||||||
<*> areq tagField "Enter tags" Nothing
|
<*> areq tagField "Enter tags" Nothing
|
||||||
-- <*> areq (selectField albums) "Album" Nothing
|
<*> areq (selectField albums) "Album" Nothing
|
||||||
-- where
|
where
|
||||||
-- albums :: Handler App App (OptionList AlbumId)
|
-- albums :: GHandler App App (OptionList AlbumId)
|
||||||
-- albums = do
|
albums = do
|
||||||
-- runDB $ selectList [AlbumOwner ==. userId] [Desc AlbumTitle]
|
entities <- runDB $ selectList [AlbumOwner ==. userId] [Desc AlbumTitle]
|
||||||
|
optionsPairs $ I.map (\alb -> (albumTitle $ entityVal alb, entityKey alb)) entities
|
||||||
|
|
||||||
tagField :: Field Handler [Text]
|
tagField :: Field Handler [Text]
|
||||||
tagField = Field
|
tagField = Field
|
||||||
|
|
|
@ -10,7 +10,7 @@ Token
|
||||||
deriving
|
deriving
|
||||||
Album
|
Album
|
||||||
title Text
|
title Text
|
||||||
owner [UserId]
|
owner UserId
|
||||||
content [MediumId]
|
content [MediumId]
|
||||||
deriving
|
deriving
|
||||||
Medium
|
Medium
|
||||||
|
|
Loading…
Reference in a new issue