Mercurial > kallithea
changeset 5156:b3299a079fa6
comments: introduce .url method for linking to originating PR or changeset page
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 27 May 2015 23:15:36 +0200 |
parents | d8993baa00dc |
children | 765fe407eda4 |
files | kallithea/model/db.py kallithea/templates/changelog/changelog.html kallithea/templates/changelog/changelog_summary_data.html kallithea/templates/changeset/changeset_file_comment.html kallithea/templates/compare/compare_cs.html |
diffstat | 5 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/db.py Wed May 27 23:15:36 2015 +0200 +++ b/kallithea/model/db.py Wed May 27 23:15:36 2015 +0200 @@ -2183,6 +2183,13 @@ q = q.filter(cls.pull_request_id == pull_request_id) return q.all() + def url(self): + anchor = "comment-%s" % self.comment_id + import kallithea.lib.helpers as h + if self.revision: + return h.url('changeset_home', repo_name=self.repo.repo_name, revision=self.revision, anchor=anchor) + elif self.pull_request_id is not None: + return self.pull_request.url(anchor=anchor) class ChangesetStatus(Base, BaseModel): __tablename__ = 'changeset_statuses'
--- a/kallithea/templates/changelog/changelog.html Wed May 27 23:15:36 2015 +0200 +++ b/kallithea/templates/changelog/changelog.html Wed May 27 23:15:36 2015 +0200 @@ -93,7 +93,7 @@ <i class="icon-circle changeset-status-${c.statuses.get(cs.raw_id)[0]}"></i> </a> %else: - <a class="tooltip" title="${_('Changeset status: %s') % c.statuses.get(cs.raw_id)[1]}" href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.comments[cs.raw_id][0].comment_id)}"> + <a class="tooltip" title="${_('Changeset status: %s') % c.statuses.get(cs.raw_id)[1]}" href="${c.comments[cs.raw_id][0].url()}"> <i class="icon-circle changeset-status-${c.statuses.get(cs.raw_id)[0]}"></i> </a> %endif @@ -122,7 +122,7 @@ %if c.comments.get(cs.raw_id): <div class="comments-container"> <div class="comments-cnt" title="${_('Changeset has comments')}"> - <a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.comments[cs.raw_id][0].comment_id)}"> + <a href="${c.comments[cs.raw_id][0].url()}"> ${len(c.comments[cs.raw_id])} <i class="icon-comment-discussion"></i> </a>
--- a/kallithea/templates/changelog/changelog_summary_data.html Wed May 27 23:15:36 2015 +0200 +++ b/kallithea/templates/changelog/changelog_summary_data.html Wed May 27 23:15:36 2015 +0200 @@ -31,7 +31,7 @@ %if c.comments.get(cs.raw_id,[]): <div class="comments-container"> <div title="${('comments')}"> - <a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.comments[cs.raw_id][0].comment_id)}"> + <a href="${c.comments[cs.raw_id][0].url()}"> <i class="icon-comment"></i>${len(c.comments[cs.raw_id])} </a> </div>
--- a/kallithea/templates/changeset/changeset_file_comment.html Wed May 27 23:15:36 2015 +0200 +++ b/kallithea/templates/changeset/changeset_file_comment.html Wed May 27 23:15:36 2015 +0200 @@ -22,7 +22,7 @@ %else: ${_('on this changeset')} %endif - <a class="permalink" href="#comment-${co.comment_id}">¶</a> + <a class="permalink" href="${co.url()}">¶</a> </span> %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or co.author.user_id == c.authuser.user_id:
--- a/kallithea/templates/compare/compare_cs.html Wed May 27 23:15:36 2015 +0200 +++ b/kallithea/templates/compare/compare_cs.html Wed May 27 23:15:36 2015 +0200 @@ -28,7 +28,7 @@ %if c.cs_comments.get(cs.raw_id): <div class="comments-container"> <div class="comments-cnt" title="${_('Changeset has comments')}"> - <a href="${h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.cs_comments[cs.raw_id][0].comment_id)}"> + <a href="${c.cs_comments[cs.raw_id][0].url()}"> ${len(c.cs_comments[cs.raw_id])} <i class="icon-comment"></i> </a>