diff rhodecode/controllers/pullrequests.py @ 2489:a0adf8db1416 beta

Enabled inline comments in pull-requests
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 19 Jun 2012 23:07:23 +0200
parents 995d938ce14b
children fddd8e3fc157
line wrap: on
line diff
--- a/rhodecode/controllers/pullrequests.py	Tue Jun 19 22:28:44 2012 +0200
+++ b/rhodecode/controllers/pullrequests.py	Tue Jun 19 23:07:23 2012 +0200
@@ -25,7 +25,7 @@
 import logging
 import traceback
 
-from webob.exc import HTTPNotFound
+from webob.exc import HTTPNotFound, HTTPForbidden
 from collections import defaultdict
 from itertools import groupby
 
@@ -39,7 +39,8 @@
 from rhodecode.lib import helpers as h
 from rhodecode.lib import diffs
 from rhodecode.lib.utils import action_logger
-from rhodecode.model.db import User, PullRequest, ChangesetStatus
+from rhodecode.model.db import User, PullRequest, ChangesetStatus,\
+    ChangesetComment
 from rhodecode.model.pull_request import PullRequestModel
 from rhodecode.model.meta import Session
 from rhodecode.model.repo import RepoModel
@@ -189,7 +190,8 @@
         for f in _parsed:
             fid = h.FID('', f['filename'])
             c.files.append([fid, f['operation'], f['filename'], f['stats']])
-            diff = diff_processor.as_html(enable_comments=False, diff_lines=[f])
+            diff = diff_processor.as_html(enable_comments=True,
+                                          diff_lines=[f])
             c.changes[fid] = [f['operation'], f['filename'], diff]
 
     def show(self, repo_name, pull_request_id):
@@ -295,3 +297,14 @@
                          render('changeset/changeset_comment_block.html')})
 
         return data
+
+    @jsonify
+    def delete_comment(self, repo_name, comment_id):
+        co = ChangesetComment.get(comment_id)
+        owner = lambda: co.author.user_id == c.rhodecode_user.user_id
+        if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner:
+            ChangesetCommentsModel().delete(comment=co)
+            Session.commit()
+            return True
+        else:
+            raise HTTPForbidden()
\ No newline at end of file