Merged r6098 from trunk.

Added Project#enable_module! and Project#disable_module!

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6104 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth
2011-06-20 19:39:59 +00:00
parent df37e5cfab
commit 16ba6bcb77
18 changed files with 131 additions and 60 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ class Attachment < ActiveRecord::Base
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
cattr_accessor :storage_path
@@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{RAILS_ROOT}/files"
@@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
def validate
if self.filesize > Setting.attachment_max_size.to_i.kilobytes
+21 -1
View File
@@ -544,7 +544,27 @@ class Project < ActiveRecord::Base
def enabled_module_names
enabled_modules.collect(&:name)
end
# Enable a specific module
#
# Examples:
# project.enable_module!(:issue_tracking)
# project.enable_module!("issue_tracking")
def enable_module!(name)
enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
end
# Disable a module if it exists
#
# Examples:
# project.disable_module!(:issue_tracking)
# project.disable_module!("issue_tracking")
# project.disable_module!(project.enabled_modules.first)
def disable_module!(target)
target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
target.destroy unless target.blank?
end
safe_attributes 'name',
'description',
'homepage',
+1 -1
View File
@@ -75,7 +75,7 @@ class Setting < ActiveRecord::Base
TIS-620)
cattr_accessor :available_settings
@@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))
@@available_settings = YAML::load(File.open("#{Rails.root}/config/settings.yml"))
Redmine::Plugin.all.each do |plugin|
next unless plugin.settings
@@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true}