##// END OF EJS Templates
set default category_id instead of the object (#11665)...
set default category_id instead of the object (#11665) Rails 2.3 still has issues with synchronizing the association_id and association attributes of an object. That means, if you set the association with an object first and then just set the id afterwards, the object wins and the setting of the id gets lost. This is not an issue in Rails >= 3.1 anymore. Contributed by Holger Just. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10226 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9252:a4c0c18e3dd0
r10043:14dcefaa97f9
Show More
issue_relations_controller.rb
95 lines | 3.0 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 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
Merged r9384, r9385 from trunk....
r9252 if params[:relation] && m = params[:relation][:issue_to_id].to_s.strip.match(/^#?(\d+)$/)
Jean-Philippe Lang
Issue relation: fixes error with postgres when entering a non-numeric id (#4820) + accept hash (#) before id....
r3299 @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
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|
Etienne Massip
Explicitly declare all routes and deactivate default route....
r8042 format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
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