Commit f4b169543c878cc28c270f714430566e0c0e863c
1 parent
ac91f04e
Exists in
master
and in
5 other branches
Add task to create templates of sofware, institution and profiles
Signed-off-by: Parley Martins <parley@outlook.com> Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Showing
1 changed file
with
95 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,95 @@ | @@ -0,0 +1,95 @@ | ||
| 1 | +namespace :templates do | ||
| 2 | + namespace :create do | ||
| 3 | + | ||
| 4 | + desc "Create new templates of software, intitution, person and community" | ||
| 5 | + task :all => :environment do | ||
| 6 | + Rake::Task["templates:create:institution"].invoke | ||
| 7 | + Rake::Task["templates:create:software"].invoke | ||
| 8 | + Rake::Task["templates:create:people"].invoke | ||
| 9 | + Rake::Task["templates:create:community"].invoke | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + desc "Create new templates of software" | ||
| 13 | + task :software => :environment do | ||
| 14 | + Environment.all.each do |env| | ||
| 15 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | ||
| 16 | + puts "Software successfully created!" | ||
| 17 | + end | ||
| 18 | + end | ||
| 19 | + end | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + desc "Create new templates of people" | ||
| 23 | + task :people => :environment do | ||
| 24 | + Environment.all.each do |env| | ||
| 25 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | ||
| 26 | + puts "Person successfully created!" | ||
| 27 | + end | ||
| 28 | + end | ||
| 29 | + end | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + desc "Create new templates of community" | ||
| 33 | + task :community => :environment do | ||
| 34 | + Environment.all.each do |env| | ||
| 35 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | ||
| 36 | + puts "Community successfully created!" | ||
| 37 | + end | ||
| 38 | + end | ||
| 39 | + end | ||
| 40 | + | ||
| 41 | + desc "Create new templates of intitution" | ||
| 42 | + task :institution => :environment do | ||
| 43 | + Environment.all.each do |env| | ||
| 44 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | ||
| 45 | + community = Community.create!(:name => "institution", :is_template => true, :moderated_articles => true) | ||
| 46 | + community.layout_template = "leftbar" | ||
| 47 | + | ||
| 48 | + box2 = community.boxes.where(:position => 2).first | ||
| 49 | + box1 = community.boxes.where(:position => 1).first | ||
| 50 | + box3 = community.boxes.where(:position => 3).first | ||
| 51 | + | ||
| 52 | + box2.blocks.destroy_all | ||
| 53 | + box1.blocks.destroy_all | ||
| 54 | + box3.blocks.destroy_all | ||
| 55 | + | ||
| 56 | + community.save! | ||
| 57 | + puts "Institution succesfully created!" | ||
| 58 | + | ||
| 59 | + members_block = MembersBlock.new | ||
| 60 | + members_block.limit = 16 | ||
| 61 | + members_block.prioritize_profiles_with_image = true | ||
| 62 | + members_block.show_join_leave_button = false | ||
| 63 | + members_block.display_user = "all" | ||
| 64 | + members_block.language = "all" | ||
| 65 | + members_block.display = "always" | ||
| 66 | + members_block.position = 2 | ||
| 67 | + members_block.save! | ||
| 68 | + box1.blocks << members_block | ||
| 69 | + box1.save! | ||
| 70 | + puts "MembersBlock successfully added!" | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + main_block = MainBlock.new | ||
| 74 | + main_block.position = 1 | ||
| 75 | + main_block.save! | ||
| 76 | + box1.blocks << main_block | ||
| 77 | + box1.save! | ||
| 78 | + puts "MainBlock successfully added!" | ||
| 79 | + end | ||
| 80 | + end | ||
| 81 | + end | ||
| 82 | + end | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + desc "Destroy all templates created by this namespace" | ||
| 86 | + task :destroy => :environment do | ||
| 87 | + Environment.all.each do |env| | ||
| 88 | + if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | ||
| 89 | + Community["institution"].destroy | ||
| 90 | + puts "Institution template destoyed with success!" | ||
| 91 | + end | ||
| 92 | + end | ||
| 93 | + end | ||
| 94 | +end | ||
| 95 | + |