We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 12b1cb11 authored by David L. L. Thomas's avatar David L. L. Thomas

Merge of merge-requests/20 from wolftune

parent 8f9f7d0b
......@@ -274,7 +274,7 @@ getProjectCommentAddTag comment_id project_id user_id = do
defaultLayout $(widgetFile "new_comment_tag")
-- | Handle a POST to a /moderate URL. Permission checking should occur *PRIOR TO* this function.
-- | Handle a POST to a /approve URL. Permission checking should occur *PRIOR TO* this function.
postApproveComment :: UserId -> CommentId -> Comment -> Handler ()
postApproveComment user_id comment_id comment = do
runSDB (approveCommentDB user_id comment_id comment)
......
......@@ -182,6 +182,29 @@ postClaimWikiCommentR project_handle target comment_id = do
Nothing -> redirect (WikiCommentR project_handle target comment_id)
Just (widget, form) -> defaultLayout $ previewWidget form "claim" (wikiDiscussionPage project_handle target widget)
--------------------------------------------------------------------------------
-- /approve
getApproveWikiCommentR :: Text -> Text -> CommentId -> Handler Html
getApproveWikiCommentR project_handle target comment_id = do
(widget, _) <-
makeWikiPageCommentActionWidget
makeApproveCommentWidget
project_handle
target
comment_id
def
getMaxDepth
defaultLayout (wikiDiscussionPage project_handle target widget)
postApproveWikiCommentR :: Text -> Text -> CommentId -> Handler Html
postApproveWikiCommentR project_handle target comment_id = do
(user@(Entity user_id _), _, _, comment) <- checkCommentPageRequireAuth project_handle target comment_id
checkProjectCommentActionPermission can_approve user project_handle (Entity comment_id comment)
postApproveComment user_id comment_id comment
redirect (WikiCommentR project_handle target comment_id)
--------------------------------------------------------------------------------
-- /close
......@@ -292,29 +315,6 @@ postFlagWikiCommentR project_handle target comment_id = do
Nothing -> redirect (WikiDiscussionR project_handle target)
Just (widget, form) -> defaultLayout $ previewWidget form "flag" (wikiDiscussionPage project_handle target widget)
--------------------------------------------------------------------------------
-- /moderate TODO: rename to /approve
getApproveWikiCommentR :: Text -> Text -> CommentId -> Handler Html
getApproveWikiCommentR project_handle target comment_id = do
(widget, _) <-
makeWikiPageCommentActionWidget
makeApproveCommentWidget
project_handle
target
comment_id
def
getMaxDepth
defaultLayout (wikiDiscussionPage project_handle target widget)
postApproveWikiCommentR :: Text -> Text -> CommentId -> Handler Html
postApproveWikiCommentR project_handle target comment_id = do
(user@(Entity user_id _), _, _, comment) <- checkCommentPageRequireAuth project_handle target comment_id
checkProjectCommentActionPermission can_approve user project_handle (Entity comment_id comment)
postApproveComment user_id comment_id comment
redirect (WikiCommentR project_handle target comment_id)
--------------------------------------------------------------------------------
-- /reply
......
......@@ -10,6 +10,7 @@ module Model.Comment
, commentIsEvenDepth
, commentIsFlagged
, commentIsOddDepth
, commentIsPrivate
, commentIsTopLevel
, makeCommentUsersSet
, makeApprovedComment
......@@ -121,6 +122,9 @@ commentIsOddDepth comment = not (commentIsTopLevel comment) && not (commentIsEve
commentIsFlagged :: CommentId -> DB Bool
commentIsFlagged = fmap (maybe False (const True)) . getBy . UniqueCommentFlagging
commentIsPrivate :: Comment -> Bool
commentIsPrivate comment = commentVisibility comment == VisPrivate
-- | Build a tree of comments, given the root and replies. The replies are not necessarily
-- direct or indirect descendants of the root, but rather may be siblings, nephews, etc.
-- This is done to greatly simplify the calling code of this function.
......
......@@ -429,6 +429,7 @@ commentWidget (Entity comment_id comment)
is_top_level = commentIsTopLevel comment
is_even_depth = commentIsEvenDepth comment
is_odd_depth = commentIsOddDepth comment
is_private = commentIsPrivate comment
-- TODO(mitchell): Lots of refactoring to lift this database hit up to the
-- controller layer. This currently has horrible performance - a hit *per* comment!
......
......@@ -164,7 +164,8 @@ renderWikiEditEvent project_handle edit_id wiki_edit wiki_page_map user_map = do
wiki page: #
$maybe comment <- wikiEditComment wiki_edit
#{comment}
<a style="float:right" href="@{WikiEditR project_handle (wikiPageTarget wiki_page) edit_id}">
<br>
<a href="@{WikiEditR project_handle (wikiPageTarget wiki_page) edit_id}">
see this edit version <!-- TODO: make this link to the diff instead -->
|]
......
......@@ -48,7 +48,7 @@
/p/#Text/c/#CommentId/delete DeleteProjectCommentR GET POST
/p/#Text/c/#CommentId/edit EditProjectCommentR GET POST
/p/#Text/c/#CommentId/flag FlagProjectCommentR GET POST
/p/#Text/c/#CommentId/moderate ApproveProjectCommentR GET POST
/p/#Text/c/#CommentId/approve ApproveProjectCommentR GET POST
/p/#Text/c/#CommentId/reply ReplyProjectCommentR GET POST
/p/#Text/c/#CommentId/rethread RethreadProjectCommentR GET POST
/p/#Text/c/#CommentId/retract RetractProjectCommentR GET POST
......@@ -86,7 +86,7 @@
/p/#Text/w/#Text/c/#CommentId/delete DeleteWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/edit EditWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/flag FlagWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/moderate ApproveWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/approve ApproveWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/reply ReplyWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/rethread RethreadWikiCommentR GET POST
/p/#Text/w/#Text/c/#CommentId/retract RetractWikiCommentR GET POST
......
......@@ -68,9 +68,13 @@
border-radius : 5px
.ticket-title
background-color: lightblue;
border-radius: 1em;
padding: 0.5em;
background-color : #CCDDFF
border-radius : 1em
padding : 0.5em
display : inline-block
max-width : 35em
margin : 0 1em
text-align : center
.closed
color : goldenrod
......
......@@ -25,6 +25,8 @@
<div .comment-head-item :is_preview:.preview>
<a href="@{comment_route_permalink parent_id}">
parent
$if is_private
<i style="color: brown">private comment
$maybe Entity (Key (PersistInt64 ticket_id)) _ <- mticket
<span .glyphicon .glyphicon-tag>
......@@ -83,7 +85,8 @@
The author retracted this comment ^{renderTime (commentRetractingTs retract)}
#{commentRetractingReason retract}
$maybe (flagging , flag_reasons) <- mflag
$maybe (flagging, flag_reasons) <- mflag
<div .flagged>
A user flagged this comment as a violation of the
<a href="@{WikiR "snowdrift" "conduct"}">
......
......@@ -43,13 +43,6 @@
<li>
<a href=@{ProjectsR}> Projects
$maybe Entity user_id _ <- maybe_user
<li>
<p .navbar-text .text-center>
<a href=@{ProjectsR}>
new activity
<br>
<span .badge>
TODO
<li>
$maybe (balance, pledged) <- money_info
<p .navbar-text .text-center>
......@@ -78,11 +71,3 @@
<li>
<a href=@{AuthR LoginR}>Sign In
$# TODO
$# $if not (null applications)
$# <strong>
$# <a href="@{ApplicationsR}">
$# _{MsgNewApplications (length applications)}
$# <br>
$# $else
$# ^{sb_link ApplicationsR "View Applications"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment