version_options_for_select(versions, project.default_version)
end
+ def project_default_assigned_to_options(project)
+ assignable_users = (project.assignable_users.to_a + [project.default_assigned_to]).uniq.compact
+ principals_options_for_select(assignable_users, project.default_assigned_to)
+ end
+
def format_version_sharing(sharing)
sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
l("label_version_sharing_#{sharing}")
end
end
- # Default assignment based on category
+ # Default assignment based on project or category
def default_assign
- if assigned_to.nil? && category && category.assigned_to
- self.assigned_to = category.assigned_to
+ if assigned_to.nil?
+ if category && category.assigned_to
+ self.assigned_to = category.assigned_to
+ elsif project && project.default_assigned_to
+ self.assigned_to = project.default_assigned_to
+ end
end
end
validate :validate_role
attr_protected :id
- before_destroy :set_issue_category_nil
+ before_destroy :set_issue_category_nil, :remove_from_project_default_assigned_to
scope :active, lambda { joins(:principal).where(:users => {:status => Principal::STATUS_ACTIVE})}
end
end
+ def remove_from_project_default_assigned_to
+ if user_id && project && project.default_assigned_to_id == user_id
+ # remove project based auto assignments for this member
+ project.update_column(:default_assigned_to_id, nil)
+ end
+ end
+
# Returns the roles that the member is allowed to manage
# in the project the member belongs to
def managed_roles
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
before_create :set_default_empty_values
+ before_destroy :nullify_projects_default_assigned_to
def reload(*args)
@project_ids = nil
principal
end
+ def nullify_projects_default_assigned_to
+ Project.where(default_assigned_to: self).update_all(default_assigned_to_id: nil)
+ end
+
protected
# Make sure we don't try to insert NULL values (see #4632)
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy
belongs_to :default_version, :class_name => 'Version'
+ belongs_to :default_assigned_to, :class_name => 'Principal'
has_many :time_entries, :dependent => :destroy
has_many :queries, :dependent => :delete_all
has_many :documents, :dependent => :destroy
'tracker_ids',
'issue_custom_field_ids',
'parent_id',
- 'default_version_id'
+ 'default_version_id',
+ 'default_assigned_to_id'
safe_attributes 'enabled_module_names',
:if => lambda {|project, user|
<p><%= f.select :default_version_id, project_default_version_options(@project), :include_blank => true %></p>
<% end %>
+<% if @project.safe_attribute?('default_assigned_to_id') && (default_assigned_to_options = project_default_assigned_to_options(@project)).present? %>
+ <p><%= f.select :default_assigned_to_id, default_assigned_to_options, include_blank: true %></p>
+<% end %>
+
<%= wikitoolbar_for 'project_description' %>
<% @project.custom_field_values.each do |value| %>
field_visible: Sichtbar
field_warn_on_leaving_unsaved: Vor dem Verlassen einer Seite mit ungesichertem Text im Editor warnen
field_watcher: Beobachter
+ field_default_assigned_to: Standardbearbeiter
general_csv_decimal_separator: ','
general_csv_encoding: ISO-8859-1
field_last_updated_by: Last updated by
field_full_width_layout: Full width layout
field_digest: Checksum
+ field_default_assigned_to: Default assignee
setting_app_title: Application title
setting_app_subtitle: Application subtitle
field_last_updated_by: Dernière mise à jour par
field_full_width_layout: Afficher sur toute la largeur
field_digest: Checksum
+ field_default_assigned_to: Assigné par défaut
setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application
--- /dev/null
+class AddProjectDefaultAssignedToId < ActiveRecord::Migration
+ def up
+ add_column :projects, :default_assigned_to_id, :integer, :default => nil
+ # Try to copy existing settings from the plugin if redmine_default_assign plugin was used
+ if column_exists?(:projects, :default_assignee_id, :integer)
+ Project.update_all('default_assigned_to_id = default_assignee_id')
+ end
+ end
+
+ def down
+ remove_column :projects, :default_assigned_to_id
+ end
+end