List books (#2)
This commit is contained in:
parent
efa7ed7f92
commit
a7f75ee20e
@ -27,8 +27,8 @@ data Index = Index
|
|||||||
|
|
||||||
type API = Get '[HTML] (AppView Index)
|
type API = Get '[HTML] (AppView Index)
|
||||||
:<|> Users.API
|
:<|> Users.API
|
||||||
:<|> "api" :> Channels.API
|
:<|> "api" :> "current" :> Channels.API
|
||||||
:<|> "api" :> Books.API
|
:<|> "api" :> "current" :> Books.API
|
||||||
:<|> "api" :> "1" :> Catalogue.VersionedAPI 1
|
:<|> "api" :> "1" :> Catalogue.VersionedAPI 1
|
||||||
:<|> "api" :> "current" :> Catalogue.VersionedAPI 1
|
:<|> "api" :> "current" :> Catalogue.VersionedAPI 1
|
||||||
|
|
||||||
|
@ -82,8 +82,17 @@ insertChannel username channel visibility = runMaybeT $ do
|
|||||||
return userId
|
return userId
|
||||||
|
|
||||||
channelBooks :: (MonadSelda m, MonadMask m, MonadIO m) => Username -> ChannelID -> m [Book]
|
channelBooks :: (MonadSelda m, MonadMask m, MonadIO m) => Username -> ChannelID -> m [Book]
|
||||||
channelBooks _username _channelID = do
|
channelBooks username identifier = fromRels <$> query q
|
||||||
return []
|
where
|
||||||
|
q = do
|
||||||
|
channelId :*: bookId' <- select (gen bookChannels)
|
||||||
|
channelId' :*: _ :*: owner :*: _ <- select (gen channels)
|
||||||
|
userId :*: _ :*: username' :*: _ <- select (gen users)
|
||||||
|
book@(bookId :*: _) <- select (gen books)
|
||||||
|
restrict (username' .== literal username .&& owner .== userId)
|
||||||
|
restrict (channelId .== literal identifier .&& channelId .== channelId')
|
||||||
|
restrict (bookId .== bookId')
|
||||||
|
return book
|
||||||
|
|
||||||
booksChannels :: (MonadSelda m, MonadMask m, MonadIO m) => BookID -> m [Channel]
|
booksChannels :: (MonadSelda m, MonadMask m, MonadIO m) => BookID -> m [Channel]
|
||||||
booksChannels bookId = fromRels <$> query q
|
booksChannels bookId = fromRels <$> query q
|
||||||
|
Loading…
Reference in New Issue
Block a user