1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 class IssueRelationsController < ApplicationController
19 before_filter :find_project, :authorize
22 @relation = IssueRelation.new(params[:relation])
23 @relation.issue_from = @issue
24 if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/)
25 @relation.issue_to = Issue.visible.find_by_id(m[1].to_i)
27 @relation.save if request.post?
28 respond_to do |format|
29 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
31 render :update do |page|
32 page.replace_html "relations", :partial => 'issues/relations'
33 if @relation.errors.empty?
34 page << "$('relation_delay').value = ''"
35 page << "$('relation_issue_to_id').value = ''"
43 relation = IssueRelation.find(params[:id])
44 if request.post? && @issue.relations.include?(relation)
48 respond_to do |format|
49 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
50 format.js { render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} }
56 @issue = Issue.find(params[:issue_id])
57 @project = @issue.project
58 rescue ActiveRecord::RecordNotFound