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

Commit 4a84cc3d authored by Mitchell Rosen's avatar Mitchell Rosen

unclaiming tickets implemented

parent 976d5e2c
......@@ -25,6 +25,7 @@ module Handler.Comment
, makeReplyCommentWidget
, makeRethreadCommentWidget
, makeRetractCommentWidget
, makeUnclaimCommentWidget
, postCommentTag
, postCommentApplyTag
, postCommentCreateTag
......@@ -37,6 +38,7 @@ module Handler.Comment
, postNewComment
, postRethreadComment
, postRetractComment
, postUnclaimComment
, redirectIfRethreaded
) where
......@@ -225,6 +227,7 @@ makeDeleteCommentWidget :: MakeCommentActionWidget
makeReplyCommentWidget :: MakeCommentActionWidget
makeRethreadCommentWidget :: MakeCommentActionWidget
makeRetractCommentWidget :: MakeCommentActionWidget
makeUnclaimCommentWidget :: MakeCommentActionWidget
makeApproveCommentWidget = makeCommentActionWidget can_approve approveCommentFormWidget
makeClaimCommentWidget = makeCommentActionWidget can_claim (claimCommentFormWidget Nothing)
......@@ -234,6 +237,7 @@ makeDeleteCommentWidget = makeCommentActionWidget can_delete deleteCommentFo
makeReplyCommentWidget = makeCommentActionWidget can_reply commentReplyFormWidget
makeRethreadCommentWidget = makeCommentActionWidget can_rethread rethreadCommentFormWidget
makeRetractCommentWidget = makeCommentActionWidget can_retract (retractCommentFormWidget Nothing)
makeUnclaimCommentWidget = makeCommentActionWidget can_unclaim (claimCommentFormWidget Nothing)
makeEditCommentWidget
comment
......@@ -586,6 +590,30 @@ postRetractComment user comment_id comment make_comment_handler_info = do
return (Just (comment_widget, form))
_ -> error "Error when submitting form."
postUnclaimComment :: Entity User -> CommentId -> Comment -> (CommentMods -> CommentHandlerInfo) -> Handler (Maybe (Widget, Widget))
postUnclaimComment user@(Entity user_id _) comment_id comment make_comment_handler_info = do
((result, _), _) <- runFormPost (claimCommentForm Nothing)
case result of
FormSuccess mnote -> do
lookupPostMode >>= \case
Just PostMode -> do
runDB (userUnclaimCommentDB user_id comment_id mnote)
return Nothing
_ -> do
(form, _) <- generateFormPost (claimCommentForm (Just mnote))
(comment_widget, _) <-
makeCommentActionWidget
can_unclaim
mempty
(Entity comment_id comment)
user
make_comment_handler_info
(def { mod_claim_map = M.delete comment_id })
(getMaxDepthDefault 0)
True
return (Just (comment_widget, form))
_ -> error "Error when submitting form."
getCommentTags :: CommentId -> Handler Html
getCommentTags comment_id = do
muser_id <- maybeAuthId
......
......@@ -718,11 +718,33 @@ getProjectCommentAddTagR project_handle comment_id = do
checkProjectCommentActionPermission can_add_tag user project_handle (Entity comment_id comment)
getProjectCommentAddTag comment_id project_id user_id
--------------------------------------------------------------------------------
-- /c/#CommentId/unclaim
getUnclaimProjectCommentR :: Text -> CommentId -> Handler Html
getUnclaimProjectCommentR = undefined
getUnclaimProjectCommentR project_handle comment_id = do
(widget, _) <-
makeProjectCommentActionWidget
makeUnclaimCommentWidget
project_handle
comment_id
def
getMaxDepth
defaultLayout (projectDiscussionPage project_handle widget)
postUnclaimProjectCommentR :: Text -> CommentId -> Handler Html
postUnclaimProjectCommentR = undefined
postUnclaimProjectCommentR project_handle comment_id = do
(user, (Entity project_id _), comment) <- checkCommentRequireAuth project_handle comment_id
checkProjectCommentActionPermission can_unclaim user project_handle (Entity comment_id comment)
postUnclaimComment
user
comment_id
comment
(projectCommentHandlerInfo (Just user) project_id project_handle)
>>= \case
Nothing -> redirect (ProjectCommentR project_handle comment_id)
Just (widget, form) -> defaultLayout $ previewWidget form "unclaim" (projectDiscussionPage project_handle widget)
--------------------------------------------------------------------------------
-- /contact
......
......@@ -431,11 +431,36 @@ getWikiCommentAddTagR project_handle target comment_id = do
checkProjectCommentActionPermission can_add_tag user project_handle (Entity comment_id comment)
getProjectCommentAddTag comment_id project_id user_id
--------------------------------------------------------------------------------
-- /unclaim
getUnclaimWikiCommentR :: Text -> Text -> CommentId -> Handler Html
getUnclaimWikiCommentR = undefined
getUnclaimWikiCommentR project_handle target comment_id = do
(widget, _) <-
makeWikiPageCommentActionWidget
makeUnclaimCommentWidget
project_handle
target
comment_id
def
getMaxDepth
defaultLayout (wikiDiscussionPage project_handle target widget)
postUnclaimWikiCommentR :: Text -> Text -> CommentId -> Handler Html
postUnclaimWikiCommentR = undefined
postUnclaimWikiCommentR project_handle target comment_id = do
(user, (Entity project_id _), _, comment) <- checkCommentPageRequireAuth project_handle target comment_id
checkProjectCommentActionPermission can_unclaim user project_handle (Entity comment_id comment)
postUnclaimComment
user
comment_id
comment
(wikiPageCommentHandlerInfo (Just user) project_id project_handle target)
>>= \case
Nothing -> redirect (WikiCommentR project_handle target comment_id)
Just (widget, form) -> defaultLayout $ previewWidget form "unclaim" (wikiDiscussionPage project_handle target widget)
--------------------------------------------------------------------------------
-- DEPRECATED
......
......@@ -39,6 +39,7 @@ module Model.User
, userMaybeViewProjectCommentsDB
, userReadNotificationsDB
, userReadVolunteerApplicationsDB
, userUnclaimCommentDB
, userUnwatchProjectDB
, userViewCommentsDB
, userViewWikiEditsDB
......@@ -389,10 +390,15 @@ userCanDeleteCommentDB user_id (Entity comment_id comment) =
then return True
else return False
-- TODO: claim event
userClaimCommentDB :: UserId -> CommentId -> Maybe Text -> DB ()
userClaimCommentDB user_id comment_id mnote = liftIO getCurrentTime >>= \now ->
insert_ (TicketClaiming now user_id comment_id mnote)
-- TODO: unclaim event
userUnclaimCommentDB :: UserId -> CommentId -> Maybe Text -> DB ()
userUnclaimCommentDB _ comment_id _ = deleteBy (UniqueTicketClaiming comment_id)
-- | Fetch a User's number of unviewed comments on each WikiPage of a Project.
fetchNumUnviewedCommentsOnProjectWikiPagesDB :: UserId -> ProjectId -> DB (Map WikiPageId Int)
fetchNumUnviewedCommentsOnProjectWikiPagesDB user_id project_id = fmap (M.fromList . map unwrapValues) $
......
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