Show More
@@ -98,15 +98,13 b' class ChangesetController(BaseRepoContro' | |||
|
98 | 98 | c.cut_off = False # defines if cut off limit is reached |
|
99 | 99 | |
|
100 | 100 | c.comments = [] |
|
101 | for cs in c.cs_ranges: | |
|
102 | c.comments.extend(ChangesetComment.query()\ | |
|
103 | .filter(ChangesetComment.repo_id == c.rhodecode_db_repo.repo_id)\ | |
|
104 | .filter(ChangesetComment.commit_id == cs.raw_id)\ | |
|
105 | .filter(ChangesetComment.line_no == None)\ | |
|
106 | .filter(ChangesetComment.f_path == None).all()) | |
|
107 | 101 | |
|
108 | 102 | # Iterate over ranges (default changeset view is always one changeset) |
|
109 | 103 | for changeset in c.cs_ranges: |
|
104 | c.comments.extend(ChangesetCommentsModel()\ | |
|
105 | .get_comments(c.rhodecode_db_repo.repo_id, | |
|
106 | changeset.raw_id)) | |
|
107 | ||
|
110 | 108 | c.changes[changeset.raw_id] = [] |
|
111 | 109 | try: |
|
112 | 110 | changeset_parent = changeset.parents[0] |
@@ -272,7 +270,7 b' class ChangesetController(BaseRepoContro' | |||
|
272 | 270 | ccmodel.create(text=request.POST.get('text'), |
|
273 | 271 | repo_id=c.rhodecode_db_repo.repo_id, |
|
274 | 272 | user_id=c.rhodecode_user.user_id, |
|
275 |
|
|
|
273 | revision=revision, f_path=request.POST.get('f_path'), | |
|
276 | 274 | line_no = request.POST.get('line')) |
|
277 | 275 | |
|
278 | 276 | return redirect(h.url('changeset_home', repo_name=repo_name, |
@@ -29,6 +29,7 b' import traceback' | |||
|
29 | 29 | |
|
30 | 30 | from rhodecode.model import BaseModel |
|
31 | 31 | from rhodecode.model.db import ChangesetComment |
|
32 | from sqlalchemy.util.compat import defaultdict | |
|
32 | 33 | |
|
33 | 34 | log = logging.getLogger(__name__) |
|
34 | 35 | |
@@ -36,7 +37,7 b' log = logging.getLogger(__name__)' | |||
|
36 | 37 | class ChangesetCommentsModel(BaseModel): |
|
37 | 38 | |
|
38 | 39 | |
|
39 |
def create(self, text, repo_id, user_id, |
|
|
40 | def create(self, text, repo_id, user_id, revision, f_path=None, | |
|
40 | 41 | line_no=None): |
|
41 | 42 | """ |
|
42 | 43 | Creates new comment for changeset |
@@ -44,7 +45,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
44 | 45 | :param text: |
|
45 | 46 | :param repo_id: |
|
46 | 47 | :param user_id: |
|
47 |
:param |
|
|
48 | :param revision: | |
|
48 | 49 | :param f_path: |
|
49 | 50 | :param line_no: |
|
50 | 51 | """ |
@@ -52,7 +53,7 b' class ChangesetCommentsModel(BaseModel):' | |||
|
52 | 53 | comment = ChangesetComment() |
|
53 | 54 | comment.repo_id = repo_id |
|
54 | 55 | comment.user_id = user_id |
|
55 | comment.commit_id = commit_id | |
|
56 | comment.revision = revision | |
|
56 | 57 | comment.text = text |
|
57 | 58 | comment.f_path = f_path |
|
58 | 59 | comment.line_no = line_no |
@@ -71,3 +72,22 b' class ChangesetCommentsModel(BaseModel):' | |||
|
71 | 72 | self.sa.delete(comment) |
|
72 | 73 | self.sa.commit() |
|
73 | 74 | return comment |
|
75 | ||
|
76 | ||
|
77 | def get_comments(self, repo_id, revision): | |
|
78 | return ChangesetComment.query()\ | |
|
79 | .filter(ChangesetComment.repo_id == repo_id)\ | |
|
80 | .filter(ChangesetComment.revision == revision)\ | |
|
81 | .filter(ChangesetComment.line_no == None)\ | |
|
82 | .filter(ChangesetComment.f_path == None).all() | |
|
83 | ||
|
84 | def get_comments_for_file(self, repo_id, f_path, raw_id): | |
|
85 | comments = self.sa.query(ChangesetComment)\ | |
|
86 | .filter(ChangesetComment.repo_id == repo_id)\ | |
|
87 | .filter(ChangesetComment.commit_id == raw_id)\ | |
|
88 | .filter(ChangesetComment.f_path == f_path).all() | |
|
89 | ||
|
90 | d = defaultdict(list) | |
|
91 | for co in comments: | |
|
92 | d[co.line_no].append(co) | |
|
93 | return d.items() |
@@ -1100,7 +1100,7 b' class ChangesetComment(Base, BaseModel):' | |||
|
1100 | 1100 | __table_args__ = ({'extend_existing':True},) |
|
1101 | 1101 | comment_id = Column('comment_id', Integer(), nullable=False, primary_key=True) |
|
1102 | 1102 | repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False) |
|
1103 |
|
|
|
1103 | revision = Column('revision', String(40), nullable=False) | |
|
1104 | 1104 | line_no = Column('line_no', Integer(), nullable=True) |
|
1105 | 1105 | f_path = Column('f_path', String(1000), nullable=True) |
|
1106 | 1106 | user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False) |
General Comments 0
You need to be logged in to leave comments.
Login now