aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/comment.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2011-11-13 02:16:12 +0200
committerMarcin Kuzminski <marcin@python-works.com>2011-11-13 02:16:12 +0200
commit17816a67fb88045f295d4cb3fd5ba2f4e55d9562 (patch)
tree884207c965518b96dfb5842c10c0f486a95ce298 /rhodecode/model/comment.py
parent534123e7e5e0a5bd5b832fe08029f070f3b17df1 (diff)
#71 code-review
- simple inline comments --HG-- branch : beta
Diffstat (limited to 'rhodecode/model/comment.py')
-rw-r--r--rhodecode/model/comment.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py
index 5c7e72e2..7c92e0fa 100644
--- a/rhodecode/model/comment.py
+++ b/rhodecode/model/comment.py
@@ -49,18 +49,18 @@ class ChangesetCommentsModel(BaseModel):
:param f_path:
:param line_no:
"""
-
- comment = ChangesetComment()
- comment.repo_id = repo_id
- comment.user_id = user_id
- comment.revision = revision
- comment.text = text
- comment.f_path = f_path
- comment.line_no = line_no
-
- self.sa.add(comment)
- self.sa.commit()
- return comment
+ if text:
+ comment = ChangesetComment()
+ comment.repo_id = repo_id
+ comment.user_id = user_id
+ comment.revision = revision
+ comment.text = text
+ comment.f_path = f_path
+ comment.line_no = line_no
+
+ self.sa.add(comment)
+ self.sa.commit()
+ return comment
def delete(self, comment_id):
"""
@@ -81,13 +81,13 @@ class ChangesetCommentsModel(BaseModel):
.filter(ChangesetComment.line_no == None)\
.filter(ChangesetComment.f_path == None).all()
- def get_comments_for_file(self, repo_id, f_path, raw_id):
+ def get_inline_comments(self, repo_id, revision):
comments = self.sa.query(ChangesetComment)\
.filter(ChangesetComment.repo_id == repo_id)\
- .filter(ChangesetComment.commit_id == raw_id)\
- .filter(ChangesetComment.f_path == f_path).all()
+ .filter(ChangesetComment.revision == revision).all()
+
+ paths = defaultdict(lambda:defaultdict(list))
- d = defaultdict(list)
for co in comments:
- d[co.line_no].append(co)
- return d.items()
+ paths[co.f_path][co.line_no].append(co)
+ return paths.items()