##// END OF EJS Templates
notifications: fix threading - use line number...
Mads Kiilerich -
r4446:5e7c6970 default
parent child Browse files
Show More
@@ -79,6 +79,16 b' def canonical_url(*args, **kargs):'
79 kargs['qualified'] = True
79 kargs['qualified'] = True
80 return url(*args, **kargs)
80 return url(*args, **kargs)
81
81
82 def canonical_hostname():
83 '''Return canonical hostname of system'''
84 from kallithea import CONFIG
85 try:
86 parts = CONFIG.get('canonical_url', '').split('://', 1)
87 return parts[1].split('/', 1)[0]
88 except IndexError:
89 parts = url('home', qualified=True).split('://', 1)
90 return parts[1].split('/', 1)[0]
91
82 def html_escape(text, html_escape_table=None):
92 def html_escape(text, html_escape_table=None):
83 """Produce entities within text."""
93 """Produce entities within text."""
84 if not html_escape_table:
94 if not html_escape_table:
@@ -81,9 +81,10 b' class ChangesetCommentsModel(BaseModel):'
81 cs = repo.scm_instance.get_changeset(revision)
81 cs = repo.scm_instance.get_changeset(revision)
82 desc = "%s" % (cs.short_id)
82 desc = "%s" % (cs.short_id)
83
83
84 revision_url = h.canonical_url('changeset_home',
84 threading = ['%s-rev-%s@%s' % (repo.repo_name, revision, h.canonical_hostname())]
85 repo_name=repo.repo_name,
85 if line_no: # TODO: url to file _and_ line number
86 revision=revision)
86 threading.append('%s-rev-%s-line-%s@%s' % (repo.repo_name, revision, line_no,
87 h.canonical_hostname()))
87 comment_url = h.canonical_url('changeset_home',
88 comment_url = h.canonical_url('changeset_home',
88 repo_name=repo.repo_name,
89 repo_name=repo.repo_name,
89 revision=revision,
90 revision=revision,
@@ -112,16 +113,20 b' class ChangesetCommentsModel(BaseModel):'
112 'short_id': h.short_id(revision),
113 'short_id': h.short_id(revision),
113 'branch': cs.branch,
114 'branch': cs.branch,
114 'comment_username': user.username,
115 'comment_username': user.username,
115 'threading': [revision_url, comment_url], # TODO: url to line number
116 'threading': threading,
116 }
117 }
117 #pull request
118 #pull request
118 elif pull_request:
119 elif pull_request:
119 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
120 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
120 desc = comment.pull_request.title
121 desc = comment.pull_request.title
121 _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
122 _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
122 pr_url = h.canonical_url('pullrequest_show',
123 threading = ['%s-pr-%s@%s' % (pull_request.other_repo.repo_name,
123 repo_name=pull_request.other_repo.repo_name,
124 pull_request.pull_request_id,
124 pull_request_id=pull_request.pull_request_id)
125 h.canonical_hostname())]
126 if line_no: # TODO: url to file _and_ line number
127 threading.append('%s-pr-%s-line-%s@%s' % (pull_request.other_repo.repo_name,
128 pull_request.pull_request_id, line_no,
129 h.canonical_hostname()))
125 comment_url = h.canonical_url('pullrequest_show',
130 comment_url = h.canonical_url('pullrequest_show',
126 repo_name=pull_request.other_repo.repo_name,
131 repo_name=pull_request.other_repo.repo_name,
127 pull_request_id=pull_request.pull_request_id,
132 pull_request_id=pull_request.pull_request_id,
@@ -155,7 +160,7 b' class ChangesetCommentsModel(BaseModel):'
155 'repo_name': pull_request.other_repo.repo_name,
160 'repo_name': pull_request.other_repo.repo_name,
156 'ref': org_ref_name,
161 'ref': org_ref_name,
157 'comment_username': user.username,
162 'comment_username': user.username,
158 'threading': [pr_url, comment_url], # TODO: url to line number
163 'threading': threading,
159 }
164 }
160
165
161 return subj, body, recipients, notification_type, email_kwargs
166 return subj, body, recipients, notification_type, email_kwargs
@@ -126,6 +126,8 b' class PullRequestModel(BaseModel):'
126 #notification to reviewers
126 #notification to reviewers
127 pr_url = h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
127 pr_url = h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
128 pull_request_id=pr.pull_request_id)
128 pull_request_id=pr.pull_request_id)
129 threading = [h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
130 pull_request_id=pr.pull_request_id)]
129 subject = safe_unicode(
131 subject = safe_unicode(
130 h.link_to(
132 h.link_to(
131 _('%(user)s wants you to review pull request #%(pr_id)s: %(pr_title)s') % \
133 _('%(user)s wants you to review pull request #%(pr_id)s: %(pr_title)s') % \
@@ -146,7 +148,7 b' class PullRequestModel(BaseModel):'
146 'pr_id': pr.pull_request_id,
148 'pr_id': pr.pull_request_id,
147 'ref': org_ref_name,
149 'ref': org_ref_name,
148 'pr_username': pr.author.username,
150 'pr_username': pr.author.username,
149 'threading': [pr_url],
151 'threading': threading,
150 'is_mention': False,
152 'is_mention': False,
151 }
153 }
152 if reviewers:
154 if reviewers:
General Comments 0
You need to be logged in to leave comments. Login now