summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-05 10:56:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-05 10:56:27 +0000
commit1d4ef8964def4ecbe7a11485f72d7fbe61c55724 (patch)
tree4986d5f51daebd1ff66ac58cdf56042624e2edc3 /app/controllers
parentc4ea429acbc09205155509e9c41e111294bc8f82 (diff)
downloadredmine-1d4ef8964def4ecbe7a11485f72d7fbe61c55724.tar.gz
redmine-1d4ef8964def4ecbe7a11485f72d7fbe61c55724.zip
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8777 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/repositories_controller.rb60
1 files changed, 54 insertions, 6 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index cd467d2d7..73892b1d8 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -30,6 +30,7 @@ class RepositoriesController < ApplicationController
before_filter :find_project_by_project_id, :only => [:new, :create]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers]
+ before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_filter :authorize
accept_rss_auth :revisions
@@ -185,16 +186,56 @@ class RepositoriesController < ApplicationController
end
def revision
- raise ChangesetNotFound if @rev.blank?
- @changeset = @repository.find_changeset_by_name(@rev)
- raise ChangesetNotFound unless @changeset
-
respond_to do |format|
format.html
format.js {render :layout => false}
end
- rescue ChangesetNotFound
- show_error_not_found
+ end
+
+ # Adds a related issue to a changeset
+ # POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
+ def add_related_issue
+ @issue = @changeset.find_referenced_issue_by_id(params[:issue_id])
+ if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
+ @issue = nil
+ end
+
+ if @issue
+ @changeset.issues << @issue
+ respond_to do |format|
+ format.js {
+ render :update do |page|
+ page.replace_html "related-issues", :partial => "related_issues"
+ page.visual_effect :highlight, "related-issue-#{@issue.id}"
+ end
+ }
+ end
+ else
+ respond_to do |format|
+ format.js {
+ render :update do |page|
+ page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
+ end
+ }
+ end
+ end
+ end
+
+ # Removes a related issue from a changeset
+ # DELETE /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id
+ def remove_related_issue
+ @issue = Issue.visible.find_by_id(params[:issue_id])
+ if @issue
+ @changeset.issues.delete(@issue)
+ end
+
+ respond_to do |format|
+ format.js {
+ render :update do |page|
+ page.remove "related-issue-#{@issue.id}"
+ end if @issue
+ }
+ end
end
def diff
@@ -282,6 +323,13 @@ class RepositoriesController < ApplicationController
show_error_not_found
end
+ def find_changeset
+ if @rev.present?
+ @changeset = @repository.find_changeset_by_name(@rev)
+ end
+ show_error_not_found unless @changeset
+ end
+
def show_error_not_found
render_error :message => l(:error_scm_not_found), :status => 404
end