Refactor: Move the updating of an Issue to the #update method.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3486 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-02-25 17:01:05 +00:00
parent 19d4ddf2f2
commit c68d853bf4
4 changed files with 29 additions and 10 deletions
+25 -7
View File
@@ -198,6 +198,31 @@ class IssuesController < ApplicationController
@issue.safe_attributes = attrs
end
respond_to do |format|
format.html { }
format.xml { }
end
end
#--
# Start converting to the Rails REST controllers
#++
def update
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@priorities = IssuePriority.all
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@time_entry = TimeEntry.new
@notes = params[:notes]
journal = @issue.init_journal(User.current, @notes)
# 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]
attrs = params[:issue].dup
attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
@issue.safe_attributes = attrs
end
if request.get?
# nop
else
@@ -237,13 +262,6 @@ class IssuesController < ApplicationController
attachments.each(&:destroy)
end
#--
# Start converting to the Rails REST controllers
#++
def update
edit
end
def reply
journal = Journal.find(params[:journal_id]) if params[:journal_id]
if journal