diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-02-27 13:34:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-02-27 13:34:41 +0000 |
commit | 262741913119f61eb4ccdd21410e552fdaca159d (patch) | |
tree | 76a647109db21853c4fa4fa04335a63fe76a80a4 /app | |
parent | ca807c8d928497bc8c68310bd852a2b85c83e975 (diff) | |
download | redmine-262741913119f61eb4ccdd21410e552fdaca159d.tar.gz redmine-262741913119f61eb4ccdd21410e552fdaca159d.zip |
Keep track of issue description changes (#746).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4954 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/journals_controller.rb | 27 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 15 | ||||
-rw-r--r-- | app/models/issue.rb | 6 | ||||
-rw-r--r-- | app/models/journal_detail.rb | 9 | ||||
-rw-r--r-- | app/views/journals/diff.html.erb | 10 |
5 files changed, 47 insertions, 20 deletions
diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 189204e26..37e52ca53 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006-2008 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -16,12 +16,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class JournalsController < ApplicationController - before_filter :find_journal, :only => [:edit] + before_filter :find_journal, :only => [:edit, :diff] before_filter :find_issue, :only => [:new] before_filter :find_optional_project, :only => [:index] - before_filter :authorize, :only => [:new, :edit] + before_filter :authorize, :only => [:new, :edit, :diff] accept_key_auth :index - + menu_item :issues + helper :issues helper :queries include QueriesHelper @@ -43,6 +44,17 @@ class JournalsController < ApplicationController render_404 end + def diff + @issue = @journal.issue + if params[:detail_id].present? + @detail = @journal.details.find_by_id(params[:detail_id]) + else + @detail = @journal.details.detect {|d| d.prop_key == 'description'} + end + (render_404; return false) unless @issue && @detail + @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) + end + def new journal = Journal.find(params[:journal_id]) if params[:journal_id] if journal @@ -67,6 +79,7 @@ class JournalsController < ApplicationController end def edit + (render_403; return false) unless @journal.editable_by?(User.current) if request.post? @journal.update_attributes(:notes => params[:notes]) if params[:notes] @journal.destroy if @journal.details.empty? && @journal.notes.blank? @@ -86,10 +99,10 @@ class JournalsController < ApplicationController end end -private + private + def find_journal @journal = Journal.find(params[:id]) - (render_403; return false) unless @journal.editable_by?(User.current) @project = @journal.journalized.project rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index ec027e2e0..f9f1c41ac 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -183,7 +183,16 @@ module IssuesHelper end end - if !detail.value.blank? + if detail.property == 'attr' && detail.prop_key == 'description' + s = l(:text_journal_changed_no_detail, :label => label) + unless no_html + diff_link = link_to 'diff', + {:controller => 'journals', :action => 'diff', :id => detail.journal_id, :detail_id => detail.id}, + :title => l(:label_view_diff) + s << " (#{ diff_link })" + end + s + elsif !detail.value.blank? case detail.property when 'attr', 'cf' if !detail.old_value.blank? diff --git a/app/models/issue.rb b/app/models/issue.rb index 2810138a4..942b654e2 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -829,7 +829,7 @@ class Issue < ActiveRecord::Base def create_journal if @current_journal # attributes changes - (Issue.column_names - %w(id description root_id lft rgt lock_version created_on updated_on)).each {|c| + (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c| @current_journal.details << JournalDetail.new(:property => 'attr', :prop_key => c, :old_value => @issue_before_change.send(c), diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb index 58239006b..aa22e6f71 100644 --- a/app/models/journal_detail.rb +++ b/app/models/journal_detail.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,9 +17,4 @@ class JournalDetail < ActiveRecord::Base belongs_to :journal - - def before_save - self.value = value[0..254] if value && value.is_a?(String) - self.old_value = old_value[0..254] if old_value && old_value.is_a?(String) - end end diff --git a/app/views/journals/diff.html.erb b/app/views/journals/diff.html.erb new file mode 100644 index 000000000..21b8755e7 --- /dev/null +++ b/app/views/journals/diff.html.erb @@ -0,0 +1,10 @@ +<h2><%=h @issue.tracker %> #<%= @issue.id %></h2> +<p><%= authoring @journal.created_on, @journal.user, :label => :label_updated_time_by %></p> + +<div class="text-diff"> +<%= simple_format_without_paragraph @diff.to_html %> +</div> + +<p><%= link_to l(:button_back), issue_path(@issue), :onclick => 'history.back(); return false;' %></p> + +<% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %> |