Refactor: Replace @journal with @issue.current_journal
This removes an instance variable in #issue_update which will let it be moved to the Issue model. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3540 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7514e12d33
commit
c58dc83e74
|
@ -188,6 +188,8 @@ class IssuesController < ApplicationController
|
||||||
def edit
|
def edit
|
||||||
update_issue_from_params
|
update_issue_from_params
|
||||||
|
|
||||||
|
@journal = @issue.current_journal
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { }
|
format.html { }
|
||||||
format.xml { }
|
format.xml { }
|
||||||
|
@ -203,6 +205,7 @@ class IssuesController < ApplicationController
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@journal = @issue.current_journal
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'edit' }
|
format.html { render :action => 'edit' }
|
||||||
format.xml { render :xml => @issue.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @issue.errors, :status => :unprocessable_entity }
|
||||||
|
@ -549,7 +552,7 @@ private
|
||||||
@time_entry = TimeEntry.new
|
@time_entry = TimeEntry.new
|
||||||
|
|
||||||
@notes = params[:notes]
|
@notes = params[:notes]
|
||||||
@journal = @issue.init_journal(User.current, @notes)
|
@issue.init_journal(User.current, @notes)
|
||||||
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
||||||
if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
|
if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
|
||||||
attrs = params[:issue].dup
|
attrs = params[:issue].dup
|
||||||
|
@ -573,14 +576,14 @@ private
|
||||||
attachments = Attachment.attach_files(@issue, params[:attachments])
|
attachments = Attachment.attach_files(@issue, params[:attachments])
|
||||||
render_attachment_warning_if_needed(@issue)
|
render_attachment_warning_if_needed(@issue)
|
||||||
|
|
||||||
attachments[:files].each {|a| @journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
|
attachments[:files].each {|a| @issue.current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
|
||||||
call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => @journal})
|
call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => @issue.current_journal})
|
||||||
if @issue.save
|
if @issue.save
|
||||||
if !@journal.new_record?
|
if !@issue.current_journal.new_record?
|
||||||
# Only send notification if something was actually changed
|
# Only send notification if something was actually changed
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
end
|
end
|
||||||
call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => @journal})
|
call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => @issue.current_journal})
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,8 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
DONE_RATIO_OPTIONS = %w(issue_field issue_status)
|
DONE_RATIO_OPTIONS = %w(issue_field issue_status)
|
||||||
|
|
||||||
|
attr_reader :current_journal
|
||||||
|
|
||||||
validates_presence_of :subject, :priority, :project, :tracker, :author, :status
|
validates_presence_of :subject, :priority, :project, :tracker, :author, :status
|
||||||
validates_length_of :subject, :maximum => 255
|
validates_length_of :subject, :maximum => 255
|
||||||
validates_inclusion_of :done_ratio, :in => 0..100
|
validates_inclusion_of :done_ratio, :in => 0..100
|
||||||
|
|
Loading…
Reference in New Issue