Project

General

Profile

RE: Restrict access to projects for certain users » add_salaries_to_new_project.patch

add employees to each new project - Christophe Benz, 2010-01-28 11:28

View differences:

/home/redmine/redmine/app/models/project.rb 2010-01-26 17:49:35.000000000 +0100
255 255
    p.nil? ? nil : p.identifier.to_s.succ
256 256
  end
257 257

  
258
  def after_create
259
    field = UserCustomField.find_by_name('Employee')
260
    employee_ids = field.custom_values.find_all_by_value('1').map { |o| o.customized_id }
261
    employee_ids.each do |employee_id|
262
        self.members << Member.new(:user_id => employee_id,
263
                                   :project => self,
264
                                   :role => Role.find_by_name('Rapporteur'),
265
                                   :mail_notification => false)
266
    end
267
  end
268

  
258 269
protected
259 270
  def validate
260 271
    errors.add(parent_id, " must be a root project") if parent and parent.parent
(1-1/2)