templates.rake
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/env ruby
# encoding: utf-8
namespace :templates do
namespace :create do
desc "Create new templates of software, intitution, person and community"
task :all => :environment do
Rake::Task["templates:create:software"].invoke
end
desc "Create new templates of software"
task :software => :environment do
Environment.all.each do |env|
if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin")
software = Community["software"]
if software.nil?
software = Community.create!(:name => "Software", :identifier => "software")
end
software.layout_template = "default"
software.is_template = true
software.save!
puts "Software Template successfully created!"
end
end
end
end
desc "Destroy all templates created by this namespace"
task :destroy => :environment do
Environment.all.each do |env|
if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin")
Community["software"].destroy unless Community["software"].nil?
puts "Software template destoyed with success!"
end
end
end
end