diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-06-01 10:26:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-06-01 10:26:17 +0000 |
commit | bf76b3b286efcb4d25951bb6fcc8f59609200269 (patch) | |
tree | f88178d43f2db38f80398c92148ae48fb83cdde2 /app/models | |
parent | 5a90b6d0b52cbe419ba2f6d3f7f693beecd4d5d0 (diff) | |
download | redmine-bf76b3b286efcb4d25951bb6fcc8f59609200269.tar.gz redmine-bf76b3b286efcb4d25951bb6fcc8f59609200269.zip |
Project#all_issue_custom_fields now returns a scope.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11916 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 6e31eafd4..f5ae92f9b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -513,10 +513,14 @@ class Project < ActiveRecord::Base members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal} end - # Returns an array of all custom fields enabled for project issues + # Returns a scope of all custom fields enabled for project issues # (explictly associated custom fields and custom fields enabled for all projects) def all_issue_custom_fields - @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort + @all_issue_custom_fields ||= IssueCustomField. + sorted. + where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + + " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + + " WHERE cfp.project_id = ?)", true, id) end # Returns an array of all custom fields enabled for project time entries |