2007-09-14 15:34:08 +04:00
|
|
|
class EnabledModule < ActiveRecord::Base
|
|
|
|
belongs_to :project
|
|
|
|
|
|
|
|
validates_presence_of :name
|
|
|
|
validates_uniqueness_of :name, :scope => :project_id
|
2009-02-15 19:43:06 +03:00
|
|
|
|
|
|
|
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?
|
2009-10-25 13:30:39 +03:00
|
|
|
Wiki.create(:project => project, :start_page => 'Wiki')
|
2009-02-15 19:43:06 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-09-14 15:34:08 +04:00
|
|
|
end
|