From 1726643f2576b51d6be806ae25d6dfefdc533481 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 7 Dec 2014 03:55:25 +0100 Subject: [PATCH] fixed upload issue with shared albums --- Handler/MediumSettings.hs | 8 ++++++-- Handler/Upload.hs | 8 +++++--- templates/mediumSettings.hamlet | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Handler/MediumSettings.hs b/Handler/MediumSettings.hs index 3756813..6384a27 100644 --- a/Handler/MediumSettings.hs +++ b/Handler/MediumSettings.hs @@ -16,8 +16,10 @@ getMediumSettingsR mediumId = do case msu of Just tempUserId -> do userId <- return $ getUserIdFromText tempUserId + album <- runDB $ getJust $ mediumAlbum medium presence <- return (userId == ownerId) - case presence of + albumOwnerPresence <- return (userId == (albumOwner album)) + case presence || albumOwnerPresence of True -> do (mediumSettingsWidget, enctype) <- generateFormPost $ mediumSettingsForm medium defaultLayout $ do @@ -44,8 +46,10 @@ postMediumSettingsR mediumId = do case msu of Just tempUserId -> do userId <- return $ getUserIdFromText tempUserId + album <- runDB $ getJust $ mediumAlbum medium presence <- return (userId == ownerId) - case presence of + albumOwnerPresence <- return (userId == (albumOwner album)) + case presence || albumOwnerPresence of True -> do ((result, mediumSettingsWidget), enctype) <- runFormPost $ mediumSettingsForm medium case result of diff --git a/Handler/Upload.hs b/Handler/Upload.hs index a100ed4..4fc1060 100644 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -29,7 +29,7 @@ getUploadR = do msu <- lookupSession "userId" case msu of Just tempUserId -> do - userId <- lift $ pure $ getUserIdFromText tempUserId + userId <- return $ getUserIdFromText tempUserId (uploadWidget, enctype) <- generateFormPost (uploadForm userId) defaultLayout $ do setTitle "Eidolon :: Upload Medium" @@ -50,8 +50,10 @@ postUploadR = do fil <- return $ tempMediumFile temp case (fileContentType fil) `elem` acceptedTypes of True -> do - path <- writeOnDrive fil userId (tempMediumAlbum temp) - thumbPath <- generateThumb path userId (tempMediumAlbum temp) + albRef <- runDB $ getJust (tempMediumAlbum temp) + ownerId <- return $ albumOwner albRef + path <- writeOnDrive fil ownerId (tempMediumAlbum temp) + thumbPath <- generateThumb path ownerId (tempMediumAlbum temp) inAlbumId <- return $ tempMediumAlbum temp medium <- return $ Medium (tempMediumTitle temp) diff --git a/templates/mediumSettings.hamlet b/templates/mediumSettings.hamlet index ec9989c..f8e7fd4 100644 --- a/templates/mediumSettings.hamlet +++ b/templates/mediumSettings.hamlet @@ -6,4 +6,5 @@ $newline always
-Delete this image +$if presence == True + Delete this image