Mercurial > hg > soundsoftware-site
comparison app/controllers/.svn/text-base/journals_controller.rb.svn-base @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 8661b858af72 |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 class JournalsController < ApplicationController | 18 class JournalsController < ApplicationController |
19 before_filter :find_journal, :only => [:edit] | 19 before_filter :find_journal, :only => [:edit, :diff] |
20 before_filter :find_issue, :only => [:new] | 20 before_filter :find_issue, :only => [:new] |
21 before_filter :find_optional_project, :only => [:index] | 21 before_filter :find_optional_project, :only => [:index] |
22 before_filter :authorize, :only => [:new, :edit] | 22 before_filter :authorize, :only => [:new, :edit, :diff] |
23 accept_key_auth :index | 23 accept_key_auth :index |
24 | 24 menu_item :issues |
25 | |
25 helper :issues | 26 helper :issues |
26 helper :queries | 27 helper :queries |
27 include QueriesHelper | 28 include QueriesHelper |
28 helper :sort | 29 helper :sort |
29 include SortHelper | 30 include SortHelper |
39 end | 40 end |
40 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name) | 41 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name) |
41 render :layout => false, :content_type => 'application/atom+xml' | 42 render :layout => false, :content_type => 'application/atom+xml' |
42 rescue ActiveRecord::RecordNotFound | 43 rescue ActiveRecord::RecordNotFound |
43 render_404 | 44 render_404 |
45 end | |
46 | |
47 def diff | |
48 @issue = @journal.issue | |
49 if params[:detail_id].present? | |
50 @detail = @journal.details.find_by_id(params[:detail_id]) | |
51 else | |
52 @detail = @journal.details.detect {|d| d.prop_key == 'description'} | |
53 end | |
54 (render_404; return false) unless @issue && @detail | |
55 @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) | |
44 end | 56 end |
45 | 57 |
46 def new | 58 def new |
47 journal = Journal.find(params[:journal_id]) if params[:journal_id] | 59 journal = Journal.find(params[:journal_id]) if params[:journal_id] |
48 if journal | 60 if journal |
65 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" | 77 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" |
66 } | 78 } |
67 end | 79 end |
68 | 80 |
69 def edit | 81 def edit |
82 (render_403; return false) unless @journal.editable_by?(User.current) | |
70 if request.post? | 83 if request.post? |
71 @journal.update_attributes(:notes => params[:notes]) if params[:notes] | 84 @journal.update_attributes(:notes => params[:notes]) if params[:notes] |
72 @journal.destroy if @journal.details.empty? && @journal.notes.blank? | 85 @journal.destroy if @journal.details.empty? && @journal.notes.blank? |
73 call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) | 86 call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) |
74 respond_to do |format| | 87 respond_to do |format| |
75 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } | 88 format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } |
76 format.js { render :action => 'update' } | 89 format.js { render :action => 'update' } |
77 end | 90 end |
91 else | |
92 respond_to do |format| | |
93 format.html { | |
94 # TODO: implement non-JS journal update | |
95 render :nothing => true | |
96 } | |
97 format.js | |
98 end | |
78 end | 99 end |
79 end | 100 end |
80 | 101 |
81 private | 102 private |
103 | |
82 def find_journal | 104 def find_journal |
83 @journal = Journal.find(params[:id]) | 105 @journal = Journal.find(params[:id]) |
84 (render_403; return false) unless @journal.editable_by?(User.current) | |
85 @project = @journal.journalized.project | 106 @project = @journal.journalized.project |
86 rescue ActiveRecord::RecordNotFound | 107 rescue ActiveRecord::RecordNotFound |
87 render_404 | 108 render_404 |
88 end | 109 end |
89 | 110 |