#!/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