diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-16 17:47:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-16 17:47:41 +0000 |
commit | 446889b3f0cbb8d66d5b72605b14518f01afd17c (patch) | |
tree | 5cf2cde689b2fda95a99ce1715554a626b564d72 /app | |
parent | 4cedecad4d336780aae1e073aa41a4a9c2169c8f (diff) | |
download | redmine-446889b3f0cbb8d66d5b72605b14518f01afd17c.tar.gz redmine-446889b3f0cbb8d66d5b72605b14518f01afd17c.zip |
Added a 'Assignable' boolean on Role model.
If unchecked, issues can not be assigned to users having this role.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@649 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 10 | ||||
-rw-r--r-- | app/views/issues/change_status.rhtml | 2 | ||||
-rw-r--r-- | app/views/issues/edit.rhtml | 2 | ||||
-rw-r--r-- | app/views/projects/add_issue.rhtml | 2 | ||||
-rw-r--r-- | app/views/roles/_form.rhtml | 2 |
5 files changed, 15 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index a73160e57..0e9e7745a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -59,6 +59,11 @@ class Issue < ActiveRecord::Base if start_date && soonest_start && start_date < soonest_start errors.add :start_date, :activerecord_error_invalid end + + # validate assignment + if assigned_to && !assignable_users.include?(assigned_to) + errors.add :assigned_to_id, :activerecord_error_invalid + end end def before_create @@ -105,6 +110,11 @@ class Issue < ActiveRecord::Base @current_journal end + # Users the issue can be assigned to + def assignable_users + project.members.select {|m| m.role.assignable?}.collect {|m| m.user} + end + def spent_hours @spent_hours ||= time_entries.sum(:hours) || 0 end diff --git a/app/views/issues/change_status.rhtml b/app/views/issues/change_status.rhtml index 550a5d6e0..79a4412db 100644 --- a/app/views/issues/change_status.rhtml +++ b/app/views/issues/change_status.rhtml @@ -10,7 +10,7 @@ <div class="box"> <div class="splitcontentleft"> <p><label><%=l(:label_issue_status_new)%></label> <%= @new_status.name %></p> -<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> +<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> <p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p> </div> diff --git a/app/views/issues/edit.rhtml b/app/views/issues/edit.rhtml index 18d6e0108..f131041ed 100644 --- a/app/views/issues/edit.rhtml +++ b/app/views/issues/edit.rhtml @@ -7,7 +7,7 @@ <div class="splitcontentleft"> <p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p> <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> -<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> +<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> <%= prompt_to_remote(l(:label_issue_category_new), l(:label_issue_category_new), 'category[name]', diff --git a/app/views/projects/add_issue.rhtml b/app/views/projects/add_issue.rhtml index d35f7f484..1793ef1d8 100644 --- a/app/views/projects/add_issue.rhtml +++ b/app/views/projects/add_issue.rhtml @@ -9,7 +9,7 @@ <div class="splitcontentleft"> <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p> <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> -<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> +<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> <%= prompt_to_remote(l(:label_issue_category_new), l(:label_issue_category_new), 'category[name]', diff --git a/app/views/roles/_form.rhtml b/app/views/roles/_form.rhtml index a80d990f9..d69fff132 100644 --- a/app/views/roles/_form.rhtml +++ b/app/views/roles/_form.rhtml @@ -2,6 +2,8 @@ <div class="box"> <!--[form:role]--> <p><%= f.text_field :name, :required => true %></p> +<p><%= f.check_box :assignable %></p> +<div class="clear"></div> <h3><%=l(:label_permissions)%></h3> <% permissions = @permissions.group_by {|p| p.group_id } %> |