Changeset - 5e7c69707f08
[Not reviewed]
default
0 3 0
Mads Kiilerich - 11 years ago 2014-08-12 13:08:23
madski@unity3d.com
notifications: fix threading - use line number

TODO: Use a more stable link, something that includes the filename.
3 files changed with 26 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -79,6 +79,16 @@ def canonical_url(*args, **kargs):
 
        kargs['qualified'] = True
 
    return url(*args, **kargs)
 

	
 
def canonical_hostname():
 
    '''Return canonical hostname of system'''
 
    from kallithea import CONFIG
 
    try:
 
        parts = CONFIG.get('canonical_url', '').split('://', 1)
 
        return parts[1].split('/', 1)[0]
 
    except IndexError:
 
        parts = url('home', qualified=True).split('://', 1)
 
        return parts[1].split('/', 1)[0]
 

	
 
def html_escape(text, html_escape_table=None):
 
    """Produce entities within text."""
 
    if not html_escape_table:
kallithea/model/comment.py
Show inline comments
 
@@ -81,9 +81,10 @@ class ChangesetCommentsModel(BaseModel):
 
            cs = repo.scm_instance.get_changeset(revision)
 
            desc = "%s" % (cs.short_id)
 

	
 
            revision_url = h.canonical_url('changeset_home',
 
                repo_name=repo.repo_name,
 
                revision=revision)
 
            threading = ['%s-rev-%s@%s' % (repo.repo_name, revision, h.canonical_hostname())]
 
            if line_no: # TODO: url to file _and_ line number
 
                threading.append('%s-rev-%s-line-%s@%s' % (repo.repo_name, revision, line_no,
 
                                                           h.canonical_hostname()))
 
            comment_url = h.canonical_url('changeset_home',
 
                repo_name=repo.repo_name,
 
                revision=revision,
 
@@ -112,16 +113,20 @@ class ChangesetCommentsModel(BaseModel):
 
                'short_id': h.short_id(revision),
 
                'branch': cs.branch,
 
                'comment_username': user.username,
 
                'threading': [revision_url, comment_url], # TODO: url to line number
 
                'threading': threading,
 
            }
 
        #pull request
 
        elif pull_request:
 
            notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
 
            desc = comment.pull_request.title
 
            _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
 
            pr_url = h.canonical_url('pullrequest_show',
 
                repo_name=pull_request.other_repo.repo_name,
 
                pull_request_id=pull_request.pull_request_id)
 
            threading = ['%s-pr-%s@%s' % (pull_request.other_repo.repo_name,
 
                                          pull_request.pull_request_id,
 
                                          h.canonical_hostname())]
 
            if line_no: # TODO: url to file _and_ line number
 
                threading.append('%s-pr-%s-line-%s@%s' % (pull_request.other_repo.repo_name,
 
                                                          pull_request.pull_request_id, line_no,
 
                                                          h.canonical_hostname()))
 
            comment_url = h.canonical_url('pullrequest_show',
 
                repo_name=pull_request.other_repo.repo_name,
 
                pull_request_id=pull_request.pull_request_id,
 
@@ -155,7 +160,7 @@ class ChangesetCommentsModel(BaseModel):
 
                'repo_name': pull_request.other_repo.repo_name,
 
                'ref': org_ref_name,
 
                'comment_username': user.username,
 
                'threading': [pr_url, comment_url], # TODO: url to line number
 
                'threading': threading,
 
            }
 

	
 
        return subj, body, recipients, notification_type, email_kwargs
kallithea/model/pull_request.py
Show inline comments
 
@@ -126,6 +126,8 @@ class PullRequestModel(BaseModel):
 
        #notification to reviewers
 
        pr_url = h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
 
                       pull_request_id=pr.pull_request_id)
 
        threading = [h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
 
                                     pull_request_id=pr.pull_request_id)]
 
        subject = safe_unicode(
 
            h.link_to(
 
              _('%(user)s wants you to review pull request #%(pr_id)s: %(pr_title)s') % \
 
@@ -146,7 +148,7 @@ class PullRequestModel(BaseModel):
 
            'pr_id': pr.pull_request_id,
 
            'ref': org_ref_name,
 
            'pr_username': pr.author.username,
 
            'threading': [pr_url],
 
            'threading': threading,
 
            'is_mention': False,
 
            }
 
        if reviewers:
0 comments (0 inline, 0 general)