From 1b36875be635ffded68f8de2d3e4843280aa4c1c Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Wed, 21 Jul 2021 10:00:57 +0200 Subject: [PATCH] comments-history: fixed fetching of history for comments --- rhodecode/apps/repository/__init__.py | 2 +- rhodecode/apps/repository/views/repo_commits.py | 3 ++- rhodecode/public/js/rhodecode/routes.js | 2 +- rhodecode/public/js/src/rhodecode/comments.js | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rhodecode/apps/repository/__init__.py b/rhodecode/apps/repository/__init__.py index 750a5739..dca501c8 100644 --- a/rhodecode/apps/repository/__init__.py +++ b/rhodecode/apps/repository/__init__.py @@ -173,7 +173,7 @@ def includeme(config): config.add_route( name='repo_commit_comment_history_view', - pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/{comment_history_id}/history_view', repo_route=True) + pattern='/{repo_name:.*?[^/]}/changeset/{commit_id}/comment/{comment_id}/history_view/{comment_history_id}', repo_route=True) config.add_view( RepoCommitsView, attr='repo_commit_comment_history_view', diff --git a/rhodecode/apps/repository/views/repo_commits.py b/rhodecode/apps/repository/views/repo_commits.py index a97fd716..9940cbec 100644 --- a/rhodecode/apps/repository/views/repo_commits.py +++ b/rhodecode/apps/repository/views/repo_commits.py @@ -539,9 +539,10 @@ class RepoCommitsView(RepoAppView): @CSRFRequired() def repo_commit_comment_history_view(self): c = self.load_default_context() + comment_id = self.request.matchdict['comment_id'] comment_history_id = self.request.matchdict['comment_history_id'] - comment = ChangesetComment.get_or_404(comment_history_id) + comment = ChangesetComment.get_or_404(comment_id) comment_owner = (comment.author.user_id == self._rhodecode_db_user.user_id) if comment.draft and not comment_owner: # if we see draft comments history, we only allow this for owner diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js index a7fba8fc..bcd2da84 100644 --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -289,7 +289,7 @@ function registerRCRoutes() { pyroutes.register('repo_commit_comment_create', '/%(repo_name)s/changeset/%(commit_id)s/comment/create', ['repo_name', 'commit_id']); pyroutes.register('repo_commit_comment_delete', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_id)s/delete', ['repo_name', 'commit_id', 'comment_id']); pyroutes.register('repo_commit_comment_edit', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_id)s/edit', ['repo_name', 'commit_id', 'comment_id']); - pyroutes.register('repo_commit_comment_history_view', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_history_id)s/history_view', ['repo_name', 'commit_id', 'comment_history_id']); + pyroutes.register('repo_commit_comment_history_view', '/%(repo_name)s/changeset/%(commit_id)s/comment/%(comment_id)s/history_view/%(comment_history_id)s', ['repo_name', 'commit_id', 'comment_id', 'comment_history_id']); pyroutes.register('repo_commit_comment_preview', '/%(repo_name)s/changeset/%(commit_id)s/comment/preview', ['repo_name', 'commit_id']); pyroutes.register('repo_commit_data', '/%(repo_name)s/changeset-data/%(commit_id)s', ['repo_name', 'commit_id']); pyroutes.register('repo_commit_download', '/%(repo_name)s/changeset-download/%(commit_id)s', ['repo_name', 'commit_id']); diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js index fa94fe2e..64e25df3 100644 --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -572,7 +572,8 @@ var CommentsController = function() { 'repo_commit_comment_history_view', { 'repo_name': templateContext.repo_name, - 'commit_id': comment_id, + 'commit_id': null, // We don't need to check the commit data here... + 'comment_id': comment_id, 'comment_history_id': comment_history_id, } );