From e24d6cc2237d4898e7ad2520e34328f8dc0d5935 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 23 Feb 2010 21:26:29 +0000 Subject: Bulk edit refactoring. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3478 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'app/models/issue.rb') diff --git a/app/models/issue.rb b/app/models/issue.rb index 8a1413600..63602dd21 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -136,24 +136,6 @@ class Issue < ActiveRecord::Base end return issue end - - def bulk_edit(params) - journal = init_journal(User.current, params[:notes]) - self.tracker = params[:tracker] if params[:tracker] - self.priority = params[:priority] if params[:priority] - self.assigned_to = params[:assigned_to] if params[:assigned_to] || params[:assigned_to_id] == 'none' - self.category = params[:category] if params[:category] || params[:category_id] == 'none' - self.fixed_version = params[:fixed_version] if params[:fixed_version] || params[:fixed_version_id] == 'none' - self.start_date = params[:start_date] unless params[:start_date].blank? - self.due_date = params[:due_date] unless params[:due_date].blank? - self.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? - self.custom_field_values = params[:custom_field_values] if params[:custom_field_values] && !params[:custom_field_values].empty? - # TODO: Edit hook name - Redmine::Hook.call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => self }) - - # Don't save any change to the issue if the user is not authorized to apply the requested status - return (params[:status].nil? || (new_statuses_allowed_to(User.current).include?(params[:status]) && self.status = params[:status])) && save - end def priority_id=(pid) self.priority = nil @@ -206,7 +188,13 @@ class Issue < ActiveRecord::Base # TODO: move workflow/permission checks from controllers to here def safe_attributes=(attrs, user=User.current) return if attrs.nil? - self.attributes = attrs.reject {|k,v| !SAFE_ATTRIBUTES.include?(k)} + attrs = attrs.reject {|k,v| !SAFE_ATTRIBUTES.include?(k)} + if attrs['status_id'] + unless new_statuses_allowed_to(user).collect(&:id).include?(attrs['status_id'].to_i) + attrs.delete('status_id') + end + end + self.attributes = attrs end def done_ratio -- cgit v1.2.3