Changeset - 1bf03daafaf0
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-11-13 17:19:31
marcin@python-works.com
fixes inline comments double entries
2 files changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/comment.py
Show inline comments
 
@@ -63,31 +63,33 @@ class ChangesetCommentsModel(BaseModel):
 
            return comment
 

	
 
    def delete(self, comment_id):
 
        """
 
        Deletes given comment
 
        
 
        :param comment_id:
 
        """
 
        comment = ChangesetComment.get(comment_id)
 
        self.sa.delete(comment)
 
        self.sa.commit()
 
        return comment
 

	
 

	
 
    def get_comments(self, repo_id, revision):
 
        return ChangesetComment.query()\
 
                .filter(ChangesetComment.repo_id == repo_id)\
 
                .filter(ChangesetComment.revision == revision)\
 
                .filter(ChangesetComment.line_no == None)\
 
                .filter(ChangesetComment.f_path == None).all()
 

	
 
    def get_inline_comments(self, repo_id, revision):
 
        comments = self.sa.query(ChangesetComment)\
 
            .filter(ChangesetComment.repo_id == repo_id)\
 
            .filter(ChangesetComment.revision == revision).all()
 
            .filter(ChangesetComment.revision == revision)\
 
            .filter(ChangesetComment.line_no != None)\
 
            .filter(ChangesetComment.f_path != None).all()
 

	
 
        paths = defaultdict(lambda:defaultdict(list))
 

	
 
        for co in comments:
 
            paths[co.f_path][co.line_no].append(co)
 
        return paths.items()
rhodecode/templates/changeset/changeset.html
Show inline comments
 
@@ -140,49 +140,51 @@
 
    
 
    <div class="comments">
 
        <div class="comments-number">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div>
 
        
 
        %for path, lines in c.inline_comments:
 
            <div class="inline-comment-placeholder" path="${path} ">
 
            % for line,comments in lines.iteritems():
 
                <div class="inline-comment-placeholder-line" line="${line}"> 
 
                %for co in comments:
 
                    ${comment.comment_block(co)}
 
                %endfor
 
                </div>
 
            %endfor
 
            </div>
 
        %endfor        
 
        
 
        %for co in c.comments:
 
            ${comment.comment_block(co)}
 
        %endfor
 
        %if c.rhodecode_user.username != 'default':
 
        <div class="comment-form">
 
            ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id))}
 
            <strong>${_('Leave a comment')}</strong>
 
            <div class="clearfix">
 
                <div class="comment-help">${_('Comments parsed using RST syntax')}</div>
 
                <div class="comment-help">
 
                    ${_('Comments parsed using')} <a href="${h.url('rst_help')}">RST</a> ${_('syntax')}
 
                </div>
 
                    ${h.textarea('text')}
 
            </div>
 
            <div class="comment-button">
 
            ${h.submit('save', _('Comment'), class_='ui-button')}
 
            </div>
 
            ${h.end_form()}
 
        </div>
 
        %endif
 
    </div>
 
    <script type="text/javascript">
 
      var deleteComment = function(comment_id){
 

	
 
          var url = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}".replace('__COMMENT_ID__',comment_id);
 
          var postData = '_method=delete';
 
          var success = function(o){
 
              var n = YUD.get('comment-'+comment_id);
 
              n.parentNode.removeChild(n);
 
          }
 
          ajaxPOST(url,postData,success);
 
      }
 

	
 
      YUE.onDOMReady(function(){
 
    	  YUE.on(YUQ('.line'),'mouseenter',function(e){
 
    		  var tr = e.currentTarget;
0 comments (0 inline, 0 general)