From 96bbd94251ee3aea45590020930c5b320d152d3b Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Thu, 15 Jul 2010 15:23:43 +0200 Subject: [PATCH] adjust for acts_as_journalized --- app/controllers/issues_controller.rb | 8 ++--- app/controllers/journals_controller.rb | 41 -------------------------- app/views/journals/_notes_form.rhtml | 8 ----- app/views/journals/edit.rjs | 3 -- app/views/journals/update.rjs | 10 ------- 5 files changed, 3 insertions(+), 67 deletions(-) delete mode 100644 app/controllers/journals_controller.rb delete mode 100644 app/views/journals/_notes_form.rhtml delete mode 100644 app/views/journals/edit.rjs delete mode 100644 app/views/journals/update.rjs diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index c3d3b8bd..5f074527 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -179,8 +179,7 @@ class IssuesController < ApplicationController if @issue.save_issue_with_child_records(params, @time_entry) render_attachment_warning_if_needed(@issue) - # FIXME: current_journal.new_record? won't work no more - flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? + flash[:notice] = l(:notice_successful_update) unless @issue.current_journal == @journal respond_to do |format| format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } @@ -189,8 +188,7 @@ class IssuesController < ApplicationController end else render_attachment_warning_if_needed(@issue) - # FIXME: current_journal.new_record? won't work no more - flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? + flash[:notice] = l(:notice_successful_update) unless @issue.current_journal == @journal @journal = @issue.current_journal respond_to do |format| @@ -445,7 +443,7 @@ private attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s} @issue.safe_attributes = attrs end - + @journal = @issue.current_journal end # TODO: Refactor, lots of extra code in here diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb deleted file mode 100644 index e9fe9099..00000000 --- a/app/controllers/journals_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -# redMine - project management software -# Copyright (C) 2006-2008 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 -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class JournalsController < ApplicationController - before_filter :find_journal - - def edit - if request.post? - @journal.update_attributes(:notes => params[:notes]) if params[:notes] - @journal.destroy if @journal.details.empty? && @journal.notes.blank? - call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) - respond_to do |format| - format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } - format.js { render :action => 'update' } - end - end - end - -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 - end -end diff --git a/app/views/journals/_notes_form.rhtml b/app/views/journals/_notes_form.rhtml deleted file mode 100644 index 94c710eb..00000000 --- a/app/views/journals/_notes_form.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -<% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %> - <%= text_area_tag :notes, @journal.notes, :class => 'wiki-edit', - :rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %> - <%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %> -

<%= submit_tag l(:button_save) %> - <%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " + - "Element.show('journal-#{@journal.id}-notes'); return false;" %>

-<% end %> diff --git a/app/views/journals/edit.rjs b/app/views/journals/edit.rjs deleted file mode 100644 index 798cb0f0..00000000 --- a/app/views/journals/edit.rjs +++ /dev/null @@ -1,3 +0,0 @@ -page.hide "journal-#{@journal.id}-notes" -page.insert_html :after, "journal-#{@journal.id}-notes", - :partial => 'notes_form' diff --git a/app/views/journals/update.rjs b/app/views/journals/update.rjs deleted file mode 100644 index a83d5812..00000000 --- a/app/views/journals/update.rjs +++ /dev/null @@ -1,10 +0,0 @@ -if @journal.frozen? - # journal was destroyed - page.remove "change-#{@journal.id}" -else - page.replace "journal-#{@journal.id}-notes", render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit')) - page.show "journal-#{@journal.id}-notes" - page.remove "journal-#{@journal.id}-form" -end - -call_hook(:view_journals_update_rjs_bottom, { :page => page, :journal => @journal })