From 40add444baea5fbaa77b1ea204ef7be3d18da7fb Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 30 May 2016 14:32:20 +0000 Subject: [PATCH] Repo collaborator removal --- src/Vervis/Handler/Repo.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 4494aa9..4deb27f 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -231,7 +231,24 @@ getRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html getRepoDevR shr rp dev = error "Not implemented" deleteRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html -deleteRepoDevR shr rp dev = error "Not implemented" +deleteRepoDevR shr rp dev = do + runDB $ do + rid <- do + Entity s _ <- getBy404 $ UniqueSharer shr + Entity r _ <- getBy404 $ UniqueRepo rp s + return r + pid <- do + Entity s _ <- getBy404 $ UniqueSharer dev + Entity p _ <- getBy404 $ UniquePersonIdent s + return p + Entity cid _collab <- getBy404 $ UniqueCollab rid pid + delete cid + setMessage "Collaborator removed." + redirect $ RepoDevsR shr rp postRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html -postRepoDevR shr rp dev = error "Not implemented" +postRepoDevR shr rp dev = do + mmethod <- lookupPostParam "_method" + case mmethod of + Just "DELETE" -> deleteRepoDevR shr rp dev + _ -> notFound