aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/comment.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-06-10 18:15:00 +0200
committerMarcin Kuzminski <marcin@python-works.com>2012-06-10 18:15:00 +0200
commit044679858f446fb330abef6abda9884c92cb98a1 (patch)
tree56f361d1924ca39e2c509744a2b8a38bf5c5a192 /rhodecode/model/comment.py
parentb738f36d16e31761f0e0c74fc98da986025acb5e (diff)
- pull request generates overview based on it's params
- added page to show all pull-requests for a repository - db schema changes to support comments and inline comments for pull-requests --HG-- branch : codereview
Diffstat (limited to 'rhodecode/model/comment.py')
-rw-r--r--rhodecode/model/comment.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py
index cdd55cf7..70da8fc9 100644
--- a/rhodecode/model/comment.py
+++ b/rhodecode/model/comment.py
@@ -32,7 +32,8 @@ from sqlalchemy.util.compat import defaultdict
from rhodecode.lib.utils2 import extract_mentioned_users, safe_unicode
from rhodecode.lib import helpers as h
from rhodecode.model import BaseModel
-from rhodecode.model.db import ChangesetComment, User, Repository, Notification
+from rhodecode.model.db import ChangesetComment, User, Repository, \
+ Notification, PullRequest
from rhodecode.model.notification import NotificationModel
log = logging.getLogger(__name__)
@@ -43,6 +44,9 @@ class ChangesetCommentsModel(BaseModel):
def __get_changeset_comment(self, changeset_comment):
return self._get_instance(ChangesetComment, changeset_comment)
+ def __get_pull_request(self, pull_request):
+ return self._get_instance(PullRequest, pull_request)
+
def _extract_mentions(self, s):
user_objects = []
for username in extract_mentioned_users(s):
@@ -135,7 +139,7 @@ class ChangesetCommentsModel(BaseModel):
return comment
- def get_comments(self, repo_id, revision=None, pull_request_id=None):
+ def get_comments(self, repo_id, revision=None, pull_request=None):
"""
Get's main comments based on revision or pull_request_id
@@ -143,22 +147,24 @@ class ChangesetCommentsModel(BaseModel):
:type repo_id:
:param revision:
:type revision:
- :param pull_request_id:
- :type pull_request_id:
+ :param pull_request:
+ :type pull_request:
"""
+
q = ChangesetComment.query()\
.filter(ChangesetComment.repo_id == repo_id)\
.filter(ChangesetComment.line_no == None)\
.filter(ChangesetComment.f_path == None)
if revision:
q = q.filter(ChangesetComment.revision == revision)
- elif pull_request_id:
- q = q.filter(ChangesetComment.pull_request_id == pull_request_id)
+ elif pull_request:
+ pull_request = self.__get_pull_request(pull_request)
+ q = q.filter(ChangesetComment.pull_request == pull_request)
else:
- raise Exception('Please specify revision or pull_request_id')
+ raise Exception('Please specify revision or pull_request')
return q.all()
- def get_inline_comments(self, repo_id, revision=None, pull_request_id=None):
+ def get_inline_comments(self, repo_id, revision=None, pull_request=None):
q = self.sa.query(ChangesetComment)\
.filter(ChangesetComment.repo_id == repo_id)\
.filter(ChangesetComment.line_no != None)\
@@ -167,8 +173,9 @@ class ChangesetCommentsModel(BaseModel):
if revision:
q = q.filter(ChangesetComment.revision == revision)
- elif pull_request_id:
- q = q.filter(ChangesetComment.pull_request_id == pull_request_id)
+ elif pull_request:
+ pull_request = self.__get_pull_request(pull_request)
+ q = q.filter(ChangesetComment.pull_request == pull_request)
else:
raise Exception('Please specify revision or pull_request_id')