changed profile handling
This commit is contained in:
parent
a992307327
commit
299bc3903a
3 changed files with 27 additions and 18 deletions
|
@ -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")
|
||||
|
|
|
@ -12,6 +12,7 @@ Album
|
|||
title Text
|
||||
owner UserId
|
||||
content [MediumId]
|
||||
samplePic MediumId Maybe
|
||||
deriving
|
||||
Medium
|
||||
title Text
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
$newline always
|
||||
<h3>Profile of #{username}
|
||||
<h3>Profile of #{ownerName}
|
||||
|
||||
$if msu == (Just username)
|
||||
Coming soon: create new album
|
||||
<br>
|
||||
|
||||
$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
|
||||
<div class="thumbnails">
|
||||
<div class="single">
|
||||
|
||||
$if null recentMedia
|
||||
This user has not uploaded any images
|
||||
$else
|
||||
Newest images:
|
||||
$forall (Entity mediaId medium) <- take 10 recentMedia
|
||||
<div class="thumbnails">
|
||||
<img src=#{mediumPath medium}>
|
||||
|
|
Loading…
Reference in a new issue