personal-thesis-guidance/lib/personal_thesis_guidance/engine.rb

39 lines
2.2 KiB
Ruby

module PersonalThesisGuidance
class Engine < ::Rails::Engine
initializer "personal_thesis_guidance" do
require File.expand_path('../../../app/models/thesis_guidance_paper', __FILE__)
mp_id_maps = {}
ThesisGuidancePaper.where({'member_profile_id.0'=> {'$exists'=> false}, 'member_profile_id' => {'$ne'=> nil}}).pluck(:id, :member_profile_id).each do |jpv|
mp_id_maps[jpv[1]] = [] if !mp_id_maps[jpv[1]]
mp_id_maps[jpv[1]] << jpv[0]
end
mp_id_maps.each do |mp_id, ids|
ThesisGuidancePaper.where(:id.in => ids).update_all(member_profile_id: [mp_id])
end
OrbitApp.registration "PersonalThesisGuidance",:type=> 'ModuleApp' do
module_label 'module_name.thesis_guidance_paper'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '5', :app_name=>"ThesisGuidancePaper", :intro_app_name=>"ThesisGuidancePaperlIntro",:path=>"/plugin/personal_thesis_guidance/profile",:front_path=>"/profile",:admin_path=>"/admin/thesis_guidance_papers/",:i18n=>'module_name.thesis_guidance_paper', :module_app_name=>'PersonalThesisGuidance', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/thesis_guidance_papers/analysis"
begin
page_custom_option({year: '<%= select_tag "#{f.object_name}[custom_data_field][year][]", options_for_select((1930...(DateTime.now.year+5)).to_a.reverse, (f.object.custom_data_field[:year].to_a rescue [])), {multiple: true} %>'})
page_custom_option({thesis_guidance_type: '<% ThesisGuidanceType.all.each do |thesis_guidance_type| %><label><%= check_box_tag "#{f.object_name}[custom_data_field][thesis_guidance_type][]", thesis_guidance_type.id.to_s, (f.object.custom_data_field[:thesis_guidance_type].include?(thesis_guidance_type.id.to_s) rescue false) %><%= thesis_guidance_type.title %></label><% end %>'})
rescue => e
puts ['there_was_no_page_custom_option',e]
end
version "0.1"
desktop_enabled true
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
authorizable
frontend_enabled
icon_class_no_sidebar "icons-user"
data_count 1..10
end
end
end
end