summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-06-27 20:13:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-06-27 20:13:56 +0000
commitce6cf66f6c3af26383cd25ed012d908be4b40bae (patch)
treedfecb66fd8cca4de280494515e0ad21ec6f32dfd /app/models/project.rb
parenta4a8b6381e4a162da85319e216a770ee7bd82202 (diff)
downloadredmine-ce6cf66f6c3af26383cd25ed012d908be4b40bae.tar.gz
redmine-ce6cf66f6c3af26383cd25ed012d908be4b40bae.zip
Custom fields refactoring: most of code moved from controllers to models (using new module ActsAsCustomizable).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1592 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index f05ccb2af..a5ba246b1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -22,7 +22,6 @@ class Project < ActiveRecord::Base
has_many :members, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
has_many :users, :through => :members
- has_many :custom_values, :dependent => :delete_all, :as => :customized
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
@@ -38,7 +37,7 @@ class Project < ActiveRecord::Base
has_many :changesets, :through => :repository
has_one :wiki, :dependent => :destroy
# Custom field for the project issues
- has_and_belongs_to_many :custom_fields,
+ has_and_belongs_to_many :issue_custom_fields,
:class_name => 'IssueCustomField',
:order => "#{CustomField.table_name}.position",
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
@@ -46,6 +45,7 @@ class Project < ActiveRecord::Base
acts_as_tree :order => "name", :counter_cache => true
+ acts_as_customizable
acts_as_searchable :columns => ['name', 'description'], :project_key => 'id', :permission => nil
acts_as_event :title => Proc.new {|o| "#{l(:label_project)}: #{o.name}"},
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o.id}}
@@ -54,7 +54,6 @@ class Project < ActiveRecord::Base
validates_presence_of :name, :identifier
validates_uniqueness_of :name, :identifier
- validates_associated :custom_values, :on => :update
validates_associated :repository, :wiki
validates_length_of :name, :maximum => 30
validates_length_of :homepage, :maximum => 255
@@ -195,12 +194,8 @@ class Project < ActiveRecord::Base
# Returns an array of all custom fields enabled for project issues
# (explictly associated custom fields and custom fields enabled for all projects)
- def custom_fields_for_issues(tracker)
- all_custom_fields.select {|c| tracker.custom_fields.include? c }
- end
-
- def all_custom_fields
- @all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
+ def all_issue_custom_fields
+ @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq
end
def project