checking for album namesakes for user
This commit is contained in:
parent
d8809907d2
commit
4d936a0910
1 changed files with 18 additions and 12 deletions
|
@ -48,6 +48,9 @@ postNewAlbumR = do
|
||||||
albumForm userId
|
albumForm userId
|
||||||
case result of
|
case result of
|
||||||
FormSuccess album -> do
|
FormSuccess album -> do
|
||||||
|
namesakes <- runDB $ selectList [AlbumTitle ==. albumTitle album, albumOwner ==. userId] []
|
||||||
|
if null lamesakes
|
||||||
|
then do
|
||||||
-- Put album in Database
|
-- Put album in Database
|
||||||
albumId <- runDB $ insert album
|
albumId <- runDB $ insert album
|
||||||
-- add album reference in user
|
-- add album reference in user
|
||||||
|
@ -59,7 +62,10 @@ postNewAlbumR = do
|
||||||
liftIO $ createDirectory $ "static" </> "data" </> unpack (extractKey userId) </> unpack (extractKey albumId)
|
liftIO $ createDirectory $ "static" </> "data" </> unpack (extractKey userId) </> unpack (extractKey albumId)
|
||||||
-- outro
|
-- outro
|
||||||
setMessage "Album successfully created"
|
setMessage "Album successfully created"
|
||||||
redirect $ ProfileR userId
|
redirect $ AlbumR albumId
|
||||||
|
else do
|
||||||
|
setMessage $ "You already have an album named " ++ albumTitle album
|
||||||
|
redirect $ AlbumR $ entityKey $ head namesakes
|
||||||
_ -> do
|
_ -> do
|
||||||
setMessage "There was an error creating the album"
|
setMessage "There was an error creating the album"
|
||||||
redirect NewAlbumR
|
redirect NewAlbumR
|
||||||
|
|
Loading…
Reference in a new issue