Mercurial > hg > soundsoftware-site
diff 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 |
line wrap: on
line diff
--- a/app/controllers/.svn/text-base/journals_controller.rb.svn-base Thu Mar 03 11:40:10 2011 +0000 +++ b/app/controllers/.svn/text-base/journals_controller.rb.svn-base Thu Mar 03 11:42:28 2011 +0000 @@ -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 @@ 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 @@ 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? @@ -75,13 +88,21 @@ format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } format.js { render :action => 'update' } end + else + respond_to do |format| + format.html { + # TODO: implement non-JS journal update + render :nothing => true + } + format.js + end 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