##// END OF EJS Templates
commit-page: show unresolved TODOs on commit page below comments.
marcink -
r1385:96c503a2 default
parent child Browse files
Show More
@@ -208,6 +208,7 b' class ChangesetController(BaseRepoContro'
208 208
209 209 c.statuses = []
210 210 c.comments = []
211 c.unresolved_comments = []
211 212 if len(c.commit_ranges) == 1:
212 213 commit = c.commit_ranges[0]
213 214 c.comments = CommentsModel().get_comments(
@@ -226,6 +227,9 b' class ChangesetController(BaseRepoContro'
226 227 for pr in prs:
227 228 c.comments.extend(pr.comments)
228 229
230 c.unresolved_comments = CommentsModel()\
231 .get_commit_unresolved_todos(commit.raw_id)
232
229 233 # Iterate over ranges (default commit view is always one commit)
230 234 for commit in c.commit_ranges:
231 235 c.changes[commit.raw_id] = []
@@ -275,7 +279,6 b' class ChangesetController(BaseRepoContro'
275 279 # sort comments by how they were generated
276 280 c.comments = sorted(c.comments, key=lambda x: x.comment_id)
277 281
278
279 282 if len(c.commit_ranges) == 1:
280 283 c.commit = c.commit_ranges[0]
281 284 c.parent_tmpl = ''.join(
@@ -146,6 +146,23 b' class CommentsModel(BaseModel):'
146 146
147 147 return todos
148 148
149 def get_commit_unresolved_todos(self, commit_id, show_outdated=True):
150
151 todos = Session().query(ChangesetComment) \
152 .filter(ChangesetComment.revision == commit_id) \
153 .filter(ChangesetComment.resolved_by == None) \
154 .filter(ChangesetComment.comment_type
155 == ChangesetComment.COMMENT_TYPE_TODO)
156
157 if not show_outdated:
158 todos = todos.filter(
159 coalesce(ChangesetComment.display_state, '') !=
160 ChangesetComment.COMMENT_OUTDATED)
161
162 todos = todos.all()
163
164 return todos
165
149 166 def create(self, text, repo, user, commit_id=None, pull_request=None,
150 167 f_path=None, line_no=None, status_change=None,
151 168 status_change_type=None, comment_type=None,
@@ -241,6 +241,9 b' function scrollToElement(element, percen'
241 241 time = (time === undefined ? 100 : time);
242 242
243 243 var $element = $(element);
244 if ($element.length == 0) {
245 throw('Cannot scroll to {0}'.format(element))
246 }
244 247 var elOffset = $element.offset().top;
245 248 var elHeight = $element.height();
246 249 var windowHeight = $(window).height();
@@ -461,6 +461,7 b' var CommentsController = function() {'
461 461 };
462 462
463 463 this.scrollToComment = function(node, offset, outdated) {
464 var offset = offset || 1;
464 465 var outdated = outdated || false;
465 466 var klass = outdated ? 'div.comment-outdated' : 'div.comment-current';
466 467
@@ -486,6 +487,7 b' var CommentsController = function() {'
486 487 nextIdx = 0;
487 488 }
488 489 var $next = $(klass).eq(nextIdx);
490
489 491 var $cb = $next.closest('.cb');
490 492 $cb.removeClass('cb-collapsed');
491 493
@@ -155,6 +155,23 b''
155 155 </div>
156 156 </div>
157 157
158 <div class="fieldset">
159 <div class="left-label">
160 ${_('Unresolved TODOs')}:
161 </div>
162 <div class="right-content">
163 <div class="comments-number">
164 % if c.unresolved_comments:
165 % for co in c.unresolved_comments:
166 <a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'))"> #${co.comment_id}</a>${'' if loop.last else ','}
167 % endfor
168 % else:
169 ${_('There are no unresolved TODOs')}
170 % endif
171 </div>
172 </div>
173 </div>
174
158 175 </div> <!-- end summary-detail -->
159 176
160 177 <div id="commit-stats" class="sidebar-right">
General Comments 0
You need to be logged in to leave comments. Login now