Commit f4b169543c878cc28c270f714430566e0c0e863c

Authored by Parley
1 parent ac91f04e
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

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
lib/tasks/templates.rake 0 → 100644
... ... @@ -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 +
... ...