Show More
@@ -220,10 +220,10 b' class ChangesetController(BaseRepoContro' | |||||
220 |
|
220 | |||
221 | c.comments.extend(ChangesetCommentsModel()\ |
|
221 | c.comments.extend(ChangesetCommentsModel()\ | |
222 | .get_comments(c.rhodecode_db_repo.repo_id, |
|
222 | .get_comments(c.rhodecode_db_repo.repo_id, | |
223 | changeset.raw_id)) |
|
223 | revision=changeset.raw_id)) | |
224 | inlines = ChangesetCommentsModel()\ |
|
224 | inlines = ChangesetCommentsModel()\ | |
225 | .get_inline_comments(c.rhodecode_db_repo.repo_id, |
|
225 | .get_inline_comments(c.rhodecode_db_repo.repo_id, | |
226 | changeset.raw_id) |
|
226 | revision=changeset.raw_id) | |
227 | c.inline_comments.extend(inlines) |
|
227 | c.inline_comments.extend(inlines) | |
228 | c.changes[changeset.raw_id] = [] |
|
228 | c.changes[changeset.raw_id] = [] | |
229 | try: |
|
229 | try: | |
@@ -295,7 +295,7 b' class ChangesetController(BaseRepoContro' | |||||
295 | ) |
|
295 | ) | |
296 |
|
296 | |||
297 | # count inline comments |
|
297 | # count inline comments | |
298 |
for |
|
298 | for _, lines in c.inline_comments: | |
299 | for comments in lines.values(): |
|
299 | for comments in lines.values(): | |
300 | c.inline_cnt += len(comments) |
|
300 | c.inline_cnt += len(comments) | |
301 |
|
301 |
@@ -135,21 +135,44 b' class ChangesetCommentsModel(BaseModel):' | |||||
135 |
|
135 | |||
136 | return comment |
|
136 | return comment | |
137 |
|
137 | |||
138 | def get_comments(self, repo_id, revision): |
|
138 | def get_comments(self, repo_id, revision=None, pull_request_id=None): | |
139 | return ChangesetComment.query()\ |
|
139 | """ | |
|
140 | Get's main comments based on revision or pull_request_id | |||
|
141 | ||||
|
142 | :param repo_id: | |||
|
143 | :type repo_id: | |||
|
144 | :param revision: | |||
|
145 | :type revision: | |||
|
146 | :param pull_request_id: | |||
|
147 | :type pull_request_id: | |||
|
148 | """ | |||
|
149 | q = ChangesetComment.query()\ | |||
140 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
150 | .filter(ChangesetComment.repo_id == repo_id)\ | |
141 | .filter(ChangesetComment.revision == revision)\ |
|
|||
142 | .filter(ChangesetComment.line_no == None)\ |
|
151 | .filter(ChangesetComment.line_no == None)\ | |
143 |
.filter(ChangesetComment.f_path == None) |
|
152 | .filter(ChangesetComment.f_path == None) | |
|
153 | if revision: | |||
|
154 | q = q.filter(ChangesetComment.revision == revision) | |||
|
155 | elif pull_request_id: | |||
|
156 | q = q.filter(ChangesetComment.pull_request_id == pull_request_id) | |||
|
157 | else: | |||
|
158 | raise Exception('Please specify revision or pull_request_id') | |||
|
159 | return q.all() | |||
144 |
|
160 | |||
145 | def get_inline_comments(self, repo_id, revision): |
|
161 | def get_inline_comments(self, repo_id, revision=None, pull_request_id=None): | |
146 |
|
|
162 | q = self.sa.query(ChangesetComment)\ | |
147 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
163 | .filter(ChangesetComment.repo_id == repo_id)\ | |
148 | .filter(ChangesetComment.revision == revision)\ |
|
|||
149 | .filter(ChangesetComment.line_no != None)\ |
|
164 | .filter(ChangesetComment.line_no != None)\ | |
150 | .filter(ChangesetComment.f_path != None)\ |
|
165 | .filter(ChangesetComment.f_path != None)\ | |
151 | .order_by(ChangesetComment.comment_id.asc())\ |
|
166 | .order_by(ChangesetComment.comment_id.asc())\ | |
152 | .all() |
|
167 | ||
|
168 | if revision: | |||
|
169 | q = q.filter(ChangesetComment.revision == revision) | |||
|
170 | elif pull_request_id: | |||
|
171 | q = q.filter(ChangesetComment.pull_request_id == pull_request_id) | |||
|
172 | else: | |||
|
173 | raise Exception('Please specify revision or pull_request_id') | |||
|
174 | ||||
|
175 | comments = q.all() | |||
153 |
|
176 | |||
154 | paths = defaultdict(lambda: defaultdict(list)) |
|
177 | paths = defaultdict(lambda: defaultdict(list)) | |
155 |
|
178 |
@@ -134,8 +134,10 b'' | |||||
134 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
134 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> | |
135 | ${comment.comment_inline_form(c.changeset)} |
|
135 | ${comment.comment_inline_form(c.changeset)} | |
136 |
|
136 | |||
137 | ## render comments |
|
137 | ## render comments main comments form and it status | |
138 | ${comment.comments(c.changeset)} |
|
138 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), | |
|
139 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} | |||
|
140 | ||||
139 | <script type="text/javascript"> |
|
141 | <script type="text/javascript"> | |
140 | YUE.onDOMReady(function(){ |
|
142 | YUE.onDOMReady(function(){ | |
141 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; |
|
143 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; | |
@@ -165,15 +167,7 b'' | |||||
165 | // inject comments into they proper positions |
|
167 | // inject comments into they proper positions | |
166 | var file_comments = YUQ('.inline-comment-placeholder'); |
|
168 | var file_comments = YUQ('.inline-comment-placeholder'); | |
167 | renderInlineComments(file_comments); |
|
169 | renderInlineComments(file_comments); | |
168 |
|
170 | |||
169 | YUE.on(YUD.get('show_changeset_status_box'),'change',function(e){ |
|
|||
170 | if(e.currentTarget.checked){ |
|
|||
171 | YUD.setStyle('status_block_container','display',''); |
|
|||
172 | } |
|
|||
173 | else{ |
|
|||
174 | YUD.setStyle('status_block_container','display','none'); |
|
|||
175 | } |
|
|||
176 | }) |
|
|||
177 | }) |
|
171 | }) | |
178 |
|
172 | |||
179 | </script> |
|
173 | </script> |
@@ -77,7 +77,8 b'' | |||||
77 | </%def> |
|
77 | </%def> | |
78 |
|
78 | |||
79 |
|
79 | |||
80 | <%def name="inlines(changeset)"> |
|
80 | ## generates inlines taken from c.comments var | |
|
81 | <%def name="inlines()"> | |||
81 | <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div> |
|
82 | <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div> | |
82 | %for path, lines in c.inline_comments: |
|
83 | %for path, lines in c.inline_comments: | |
83 | % for line,comments in lines.iteritems(): |
|
84 | % for line,comments in lines.iteritems(): | |
@@ -92,11 +93,12 b'' | |||||
92 | </%def> |
|
93 | </%def> | |
93 |
|
94 | |||
94 | ## MAIN COMMENT FORM |
|
95 | ## MAIN COMMENT FORM | |
95 |
<%def name="comments( |
|
96 | <%def name="comments(post_url, cur_status)"> | |
96 |
|
97 | |||
97 | <div class="comments"> |
|
98 | <div class="comments"> | |
98 | <div id="inline-comments-container"> |
|
99 | <div id="inline-comments-container"> | |
99 |
|
|
100 | ## generate inlines for this changeset | |
|
101 | ${inlines()} | |||
100 | </div> |
|
102 | </div> | |
101 |
|
103 | |||
102 | %for co in c.comments: |
|
104 | %for co in c.comments: | |
@@ -106,7 +108,7 b'' | |||||
106 | %endfor |
|
108 | %endfor | |
107 | %if c.rhodecode_user.username != 'default': |
|
109 | %if c.rhodecode_user.username != 'default': | |
108 | <div class="comment-form ac"> |
|
110 | <div class="comment-form ac"> | |
109 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id))} |
|
111 | ${h.form(post_url)} | |
110 | <strong>${_('Leave a comment')}</strong> |
|
112 | <strong>${_('Leave a comment')}</strong> | |
111 | <div class="clearfix"> |
|
113 | <div class="clearfix"> | |
112 | <div class="comment-help"> |
|
114 | <div class="comment-help"> | |
@@ -120,7 +122,7 b'' | |||||
120 | <div id="status_block_container" class="status-block" style="display:none"> |
|
122 | <div id="status_block_container" class="status-block" style="display:none"> | |
121 | %for status,lbl in c.changeset_statuses: |
|
123 | %for status,lbl in c.changeset_statuses: | |
122 | <div class=""> |
|
124 | <div class=""> | |
123 |
<img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == |
|
125 | <img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == cur_status else ''}" type="radio" name="changeset_status" value="${status}"> <label>${lbl}</label> | |
124 | </div> |
|
126 | </div> | |
125 | %endfor |
|
127 | %endfor | |
126 | </div> |
|
128 | </div> | |
@@ -137,6 +139,17 b'' | |||||
137 | <script> |
|
139 | <script> | |
138 | YUE.onDOMReady(function () { |
|
140 | YUE.onDOMReady(function () { | |
139 | MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
141 | MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA); | |
|
142 | ||||
|
143 | // changeset status box listener | |||
|
144 | YUE.on(YUD.get('show_changeset_status_box'),'change',function(e){ | |||
|
145 | if(e.currentTarget.checked){ | |||
|
146 | YUD.setStyle('status_block_container','display',''); | |||
|
147 | } | |||
|
148 | else{ | |||
|
149 | YUD.setStyle('status_block_container','display','none'); | |||
|
150 | } | |||
|
151 | }) | |||
|
152 | ||||
140 | }); |
|
153 | }); | |
141 | </script> |
|
154 | </script> | |
142 | </%def> |
|
155 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now