##// END OF EJS Templates
Resourcified documents....
Resourcified documents. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8010 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r7861:740dc53aab0c
r7890:c3c2a4afe008
Show More
issue_relations_controller.rb
97 lines | 3.2 KiB | text/x-ruby | RubyLexer
/ app / controllers / issue_relations_controller.rb
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 # Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769 #
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769 #
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssueRelationsController < ApplicationController
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create]
before_filter :find_relation, :except => [:index, :create]
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Separation of RSS/API auth actions....
r6077 accept_api_auth :index, :show, :create, :destroy
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Adds support for GET on /issues/:issue_id/relations (#7366)....
r6059 def index
@relations = @issue.relations
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Adds support for GET on /issues/:issue_id/relations (#7366)....
r6059 respond_to do |format|
format.html { render :nothing => true }
format.api
end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 def show
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 raise Unauthorized unless @relation.visible?
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056
respond_to do |format|
format.html { render :nothing => true }
format.api
end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
def create
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 @relation = IssueRelation.new(params[:relation])
@relation.issue_from = @issue
Jean-Philippe Lang
Issue relation: fixes error with postgres when entering a non-numeric id (#4820) + accept hash (#) before id....
r3299 if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/)
@relation.issue_to = Issue.visible.find_by_id(m[1].to_i)
Jean-Philippe Lang
Fixed: users should not be able to add relations with issues they're not allowed to view (#2589)....
r2321 end
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 saved = @relation.save
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 respond_to do |format|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
format.js do
Jean-Philippe Lang
Fixed: Relations are not displayed after adding/removing an issue relation (#7463)....
r4644 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 render :update do |page|
page.replace_html "relations", :partial => 'issues/relations'
if @relation.errors.empty?
page << "$('relation_delay').value = ''"
page << "$('relation_issue_to_id').value = ''"
end
end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769 format.api {
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 if saved
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 render :action => 'show', :status => :created, :location => relation_url(@relation)
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 else
render_validation_errors(@relation)
end
}
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Adds REST API for issue relations (#7366)....
r6056 verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 def destroy
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 raise Unauthorized unless @relation.deletable?
@relation.destroy
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 respond_to do |format|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
format.api { head :ok }
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 private
Eric Davis
Refactor: Split the find_object methods to prep for a larger refactoring....
r3477 def find_issue
@issue = @object = Issue.find(params[:issue_id])
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 rescue ActiveRecord::RecordNotFound
render_404
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issue_relations_controller.rb....
r6769
Jean-Philippe Lang
Makes relations resource shallow (#7366)....
r6064 def find_relation
@relation = IssueRelation.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 end