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