diff --git a/Handler/Profile.hs b/Handler/Profile.hs index dca261d..4eb51e6 100644 --- a/Handler/Profile.hs +++ b/Handler/Profile.hs @@ -1,13 +1,18 @@ module Handler.Profile where import Import +import Data.Maybe getProfileR :: UserId -> Handler Html -getProfileR userId = error "reworking logic" -- do --- msu <- lookupSession "id" --- case msu of --- Just tempUserId -> do --- userId <- Key $ PersistInt64 $ fromIntegral tempUserId --- userMedia <- runDB $ selectList [MediumOwner ==. userId] [Desc MediumTime] --- defaultLayout $ do --- $(widgetFile "profile") +getProfileR user = do + owner <- runDB $ get user + ownerName <- lift $ pure $ userName $ fromJust owner + userAlbums <- runDB $ selectList [AlbumOwner ==. user] [Desc AlbumTitle] + recentMedia <- (runDB $ selectList [MediumOwner ==. user] [Desc MediumTime]) + msu <- lookupSession "userId" + case msu of + Just tempUserId -> do + userId <- lift $ pure $ getUserIdFromText tempUserId + presence <- lift $ pure $ (Key userId) == user + defaultLayout $ do + $(widgetFile "profile") diff --git a/config/models b/config/models index 31d8091..a62c975 100644 --- a/config/models +++ b/config/models @@ -12,6 +12,7 @@ Album title Text owner UserId content [MediumId] + samplePic MediumId Maybe deriving Medium title Text diff --git a/templates/profile.hamlet b/templates/profile.hamlet index 77ab9d1..ff7953c 100644 --- a/templates/profile.hamlet +++ b/templates/profile.hamlet @@ -1,14 +1,17 @@ $newline always -

Profile of #{username} +

Profile of #{ownerName} -$if msu == (Just username) - Coming soon: create new album -
- -$if null userMedia - Dieser Benutzer hat noch keine Medien hochgeladen. +$if null userAlbums + This user has no albums yet $else - Neueste Medien: - $forall (Entity mediaId medium) <- userMedia + Albums of this user: + $forall (Entity albumId album) <- userAlbums
-
+ +$if null recentMedia + This user has not uploaded any images +$else + Newest images: + $forall (Entity mediaId medium) <- take 10 recentMedia +
+