adding features for #19
This commit is contained in:
parent
577f8634c8
commit
28d9f80b0f
4 changed files with 14 additions and 10 deletions
|
@ -18,6 +18,7 @@ module Handler.Album where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Text.Blaze (toMarkup)
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Yesod.RssFeed
|
import Yesod.RssFeed
|
||||||
import Yesod.AtomFeed
|
import Yesod.AtomFeed
|
||||||
|
@ -54,12 +55,12 @@ getBeautyAlbumR ownerName albumName = do
|
||||||
tempOwner <- runDB $ getBy $ UniqueUser ownerName
|
tempOwner <- runDB $ getBy $ UniqueUser ownerName
|
||||||
case tempOwner of
|
case tempOwner of
|
||||||
Just (Entity ownerId _) -> do
|
Just (Entity ownerId _) -> do
|
||||||
tempAlbum <- rundB $ selectFirst [AlbumTitle ==. albumName, albumOwner ==. ownerId] []
|
tempAlbum <- runDB $ selectFirst [AlbumTitle ==. albumName, AlbumOwner ==. ownerId] []
|
||||||
case tempAlbum of
|
case tempAlbum of
|
||||||
Just (Entity albumId _) ->
|
Just (Entity albumId _) ->
|
||||||
getAlbumR albumId
|
getAlbumR albumId
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
setMessage $ "This user has no album named " `T.append` albumName
|
setMessage $ toMarkup $ "This user has no album named " `T.append` albumName
|
||||||
redirect $ UserR ownerName
|
redirect $ UserR ownerName
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
setMessage "This user does not exist"
|
setMessage "This user does not exist"
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
module Handler.NewAlbum where
|
module Handler.NewAlbum where
|
||||||
|
|
||||||
import Import
|
import Import as I
|
||||||
|
import Data.List as L (head)
|
||||||
import Data.Text as T
|
import Data.Text as T
|
||||||
|
import Text.Blaze (toMarkup)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
|
|
||||||
|
@ -48,8 +50,8 @@ 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] []
|
namesakes <- runDB $ selectList [AlbumTitle ==. albumTitle album, AlbumOwner ==. userId] []
|
||||||
if null lamesakes
|
if I.null namesakes
|
||||||
then do
|
then do
|
||||||
-- Put album in Database
|
-- Put album in Database
|
||||||
albumId <- runDB $ insert album
|
albumId <- runDB $ insert album
|
||||||
|
@ -64,8 +66,9 @@ postNewAlbumR = do
|
||||||
setMessage "Album successfully created"
|
setMessage "Album successfully created"
|
||||||
redirect $ AlbumR albumId
|
redirect $ AlbumR albumId
|
||||||
else do
|
else do
|
||||||
setMessage $ "You already have an album named " ++ albumTitle album
|
setMessage $ toMarkup $ "You already have an album named " `T.append`
|
||||||
redirect $ AlbumR $ entityKey $ head namesakes
|
albumTitle album
|
||||||
|
redirect $ AlbumR $ entityKey $ L.head namesakes
|
||||||
_ -> do
|
_ -> do
|
||||||
setMessage "There was an error creating the album"
|
setMessage "There was an error creating the album"
|
||||||
redirect NewAlbumR
|
redirect NewAlbumR
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
/logout LogoutR GET
|
/logout LogoutR GET
|
||||||
/activate/#T.Text ActivateR GET POST
|
/activate/#T.Text ActivateR GET POST
|
||||||
/profile/#UserId ProfileR GET
|
/profile/#UserId ProfileR GET
|
||||||
/#T.Text UserR GET
|
/user/#T.Text UserR GET
|
||||||
/#T.Text/T.Text BeatyAlbumR GET
|
/user/#T.Text/album/#T.Text BeautyAlbumR GET
|
||||||
/upload UploadR GET POST
|
/upload UploadR GET POST
|
||||||
/newalbum NewAlbumR GET POST
|
/newalbum NewAlbumR GET POST
|
||||||
/album/#AlbumId AlbumR GET
|
/album/#AlbumId AlbumR GET
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: eidolon
|
name: eidolon
|
||||||
version: 0.1.6.1
|
version: 0.1.7.0
|
||||||
synopsis: Image gallery in Yesod
|
synopsis: Image gallery in Yesod
|
||||||
homepage: https://eidolon.nek0.eu
|
homepage: https://eidolon.nek0.eu
|
||||||
license: AGPL-3
|
license: AGPL-3
|
||||||
|
|
Loading…
Reference in a new issue