Mercurial > hg > soundsoftware-site
comparison app/controllers/issue_relations_controller.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | 0579821a129a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 # | |
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. | |
8 # | |
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. | |
13 # | |
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. | |
17 | |
18 class IssueRelationsController < ApplicationController | |
19 before_filter :find_issue, :find_project_from_association, :authorize | |
20 | |
21 def new | |
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) | |
26 end | |
27 @relation.save if request.post? | |
28 respond_to do |format| | |
29 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } | |
30 format.js do | |
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 = ''" | |
36 end | |
37 end | |
38 end | |
39 end | |
40 end | |
41 | |
42 def destroy | |
43 relation = IssueRelation.find(params[:id]) | |
44 if request.post? && @issue.relations.include?(relation) | |
45 relation.destroy | |
46 @issue.reload | |
47 end | |
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'} } | |
51 end | |
52 end | |
53 | |
54 private | |
55 def find_issue | |
56 @issue = @object = Issue.find(params[:issue_id]) | |
57 rescue ActiveRecord::RecordNotFound | |
58 render_404 | |
59 end | |
60 end |