Feature #482 » 482.patch
app/helpers/projects_helper.rb | ||
---|---|---|
89 | 89 |
version_options_for_select(versions, project.default_version) |
90 | 90 |
end |
91 | 91 | |
92 |
def project_default_assigned_to_options(project) |
|
93 |
assignable_users = (project.assignable_users.to_a + [project.default_assigned_to]).uniq.compact |
|
94 |
principals_options_for_select(assignable_users, project.default_assigned_to) |
|
95 |
end |
|
96 | ||
92 | 97 |
def format_version_sharing(sharing) |
93 | 98 |
sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) |
94 | 99 |
l("label_version_sharing_#{sharing}") |
app/models/issue.rb | ||
---|---|---|
1751 | 1751 |
end |
1752 | 1752 |
end |
1753 | 1753 | |
1754 |
# Default assignment based on category |
|
1754 |
# Default assignment based on project or category
|
|
1755 | 1755 |
def default_assign |
1756 |
if assigned_to.nil? && category && category.assigned_to |
|
1757 |
self.assigned_to = category.assigned_to |
|
1756 |
if assigned_to.nil? |
|
1757 |
if category && category.assigned_to |
|
1758 |
self.assigned_to = category.assigned_to |
|
1759 |
elsif project && project.default_assigned_to |
|
1760 |
self.assigned_to = project.default_assigned_to |
|
1761 |
end |
|
1758 | 1762 |
end |
1759 | 1763 |
end |
1760 | 1764 |
app/models/member.rb | ||
---|---|---|
27 | 27 |
validate :validate_role |
28 | 28 |
attr_protected :id |
29 | 29 | |
30 |
before_destroy :set_issue_category_nil |
|
30 |
before_destroy :set_issue_category_nil, :remove_from_project_default_assigned_to
|
|
31 | 31 | |
32 | 32 |
scope :active, lambda { joins(:principal).where(:users => {:status => Principal::STATUS_ACTIVE})} |
33 | 33 | |
... | ... | |
151 | 151 |
end |
152 | 152 |
end |
153 | 153 | |
154 |
def remove_from_project_default_assigned_to |
|
155 |
if user_id && project && project.default_assigned_to_id == user_id |
|
156 |
# remove project based auto assignments for this member |
|
157 |
project.update_column(:default_assigned_to_id, nil) |
|
158 |
end |
|
159 |
end |
|
160 | ||
154 | 161 |
# Returns the roles that the member is allowed to manage |
155 | 162 |
# in the project the member belongs to |
156 | 163 |
def managed_roles |
app/models/principal.rb | ||
---|---|---|
106 | 106 |
scope :sorted, lambda { order(*Principal.fields_for_order_statement)} |
107 | 107 | |
108 | 108 |
before_create :set_default_empty_values |
109 |
before_destroy :nullify_projects_default_assigned_to |
|
109 | 110 | |
110 | 111 |
def reload(*args) |
111 | 112 |
@project_ids = nil |
... | ... | |
181 | 182 |
principal |
182 | 183 |
end |
183 | 184 | |
185 |
def nullify_projects_default_assigned_to |
|
186 |
Project.where(default_assigned_to: self).update_all(default_assigned_to_id: nil) |
|
187 |
end |
|
188 | ||
184 | 189 |
protected |
185 | 190 | |
186 | 191 |
# Make sure we don't try to insert NULL values (see #4632) |
app/models/project.rb | ||
---|---|---|
39 | 39 |
has_many :issue_changes, :through => :issues, :source => :journals |
40 | 40 |
has_many :versions, :dependent => :destroy |
41 | 41 |
belongs_to :default_version, :class_name => 'Version' |
42 |
belongs_to :default_assigned_to, :class_name => 'Principal' |
|
42 | 43 |
has_many :time_entries, :dependent => :destroy |
43 | 44 |
has_many :queries, :dependent => :delete_all |
44 | 45 |
has_many :documents, :dependent => :destroy |
... | ... | |
728 | 729 |
'tracker_ids', |
729 | 730 |
'issue_custom_field_ids', |
730 | 731 |
'parent_id', |
731 |
'default_version_id' |
|
732 |
'default_version_id', |
|
733 |
'default_assigned_to_id' |
|
732 | 734 | |
733 | 735 |
safe_attributes 'enabled_module_names', |
734 | 736 |
:if => lambda {|project, user| |
app/views/projects/_form.html.erb | ||
---|---|---|
24 | 24 |
<p><%= f.select :default_version_id, project_default_version_options(@project), :include_blank => true %></p> |
25 | 25 |
<% end %> |
26 | 26 | |
27 |
<% if @project.safe_attribute?('default_assigned_to_id') && (default_assigned_to_options = project_default_assigned_to_options(@project)).present? %> |
|
28 |
<p><%= f.select :default_assigned_to_id, default_assigned_to_options, include_blank: true %></p> |
|
29 |
<% end %> |
|
30 | ||
27 | 31 |
<%= wikitoolbar_for 'project_description' %> |
28 | 32 | |
29 | 33 |
<% @project.custom_field_values.each do |value| %> |
config/locales/de.yml | ||
---|---|---|
389 | 389 |
field_visible: Sichtbar |
390 | 390 |
field_warn_on_leaving_unsaved: Vor dem Verlassen einer Seite mit ungesichertem Text im Editor warnen |
391 | 391 |
field_watcher: Beobachter |
392 |
field_default_assigned_to: Standardbearbeiter |
|
392 | 393 | |
393 | 394 |
general_csv_decimal_separator: ',' |
394 | 395 |
general_csv_encoding: ISO-8859-1 |
config/locales/en.yml | ||
---|---|---|
373 | 373 |
field_updated_by: Updated by |
374 | 374 |
field_last_updated_by: Last updated by |
375 | 375 |
field_full_width_layout: Full width layout |
376 |
field_default_assigned_to: Default assignee |
|
376 | 377 | |
377 | 378 |
setting_app_title: Application title |
378 | 379 |
setting_app_subtitle: Application subtitle |
config/locales/fr.yml | ||
---|---|---|
385 | 385 |
field_updated_by: Mise à jour par |
386 | 386 |
field_last_updated_by: Dernière mise à jour par |
387 | 387 |
field_full_width_layout: Afficher sur toute la largeur |
388 |
field_default_assigned_to: Assigné par défaut |
|
388 | 389 | |
389 | 390 |
setting_app_title: Titre de l'application |
390 | 391 |
setting_app_subtitle: Sous-titre de l'application |
db/migrate/20170309214320_add_project_default_assigned_to_id.rb | ||
---|---|---|
1 |
class AddProjectDefaultAssignedToId < ActiveRecord::Migration |
|
2 |
def up |
|
3 |
add_column :projects, :default_assigned_to_id, :integer, :default => nil |
|
4 |
# Try to copy existing settings from the plugin if redmine_default_assign plugin was used |
|
5 |
if column_exists?(:projects, :default_assignee_id, :integer) |
|
6 |
Project.update_all('`default_assigned_to_id` = `default_assignee_id`') |
|
7 |
end |
|
8 |
end |
|
9 | ||
10 |
def down |
|
11 |
remove_column :projects, :default_assigned_to_id |
|
12 |
end |
|
13 |
end |