summaryrefslogtreecommitdiffstats
path: root/app/models/enabled_module.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-15 16:43:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-15 16:43:06 +0000
commit9e4a118528119c4f9aa67ae4003f95a47a43722a (patch)
tree9a25eeb572a70d94ce6673eaef0f77ee7eeb7cc7 /app/models/enabled_module.rb
parentb05ed594a08611267886942d2f10a52de6b08e44 (diff)
downloadredmine-9e4a118528119c4f9aa67ae4003f95a47a43722a.tar.gz
redmine-9e4a118528119c4f9aa67ae4003f95a47a43722a.zip
Create a wiki with a default start page named 'Wiki' when enabling wiki module (#2657).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2474 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/enabled_module.rb')
-rw-r--r--app/models/enabled_module.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/models/enabled_module.rb b/app/models/enabled_module.rb
index 3c05c76c1..d2aade6d3 100644
--- a/app/models/enabled_module.rb
+++ b/app/models/enabled_module.rb
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006-2007 Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2009 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -20,4 +20,19 @@ class EnabledModule < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name, :scope => :project_id
+
+ after_create :module_enabled
+
+ private
+
+ # after_create callback used to do things when a module is enabled
+ def module_enabled
+ case name
+ when 'wiki'
+ # Create a wiki with a default start page
+ if project && project.wiki.nil?
+ Wiki.create(:project => project, :start_page => 'Wiki')
+ end
+ end
+ end
end