property_hire/lib/property_hire/engine.rb

92 lines
3.6 KiB
Ruby

module PropertyHire
class Engine < ::Rails::Engine
initializer "property_hire" do
OrbitApp.registration "PropertyHire", :type => "ModuleApp" do
module_label "property_hire.property_hire"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ['widget']
widget_settings [{"data_count"=>30}]
taggable "Property"
categorizable
authorizable
frontend_enabled
data_count 1..30
require File.expand_path('../../../app/models/property_hire_setting', __FILE__)
if defined?(PropertyHireSetting)
settings_count = PropertyHireSetting.count
if settings_count == 0
PropertyHireSetting.create
elsif settings_count > 1
PropertyHireSetting.all[1..-1].each{|s| s.destroy}
end
end
if File.basename($0) != 'rake'
begin
avoid_page_cache HireEmailSet
avoid_page_cache PHire
rescue => e
puts ["avoid_page_cache", e.to_s]
end
end
side_bar do
head_label_i18n 'property_hire.property_hire', icon_class: "icons-map"
available_for "users"
active_for_controllers (['admin/property_hires'])
head_link_path "admin_property_hires_path"
context_link 'property_hire.my_bookings',
:link_path=>"my_bookings_admin_property_hires_path" ,
:priority=>1,
:active_for_action=>{'admin/property_hires'=>"my_bookings"},
:available_for => 'users'
context_link 'all',
:link_path=>"admin_property_hires_path" ,
:priority=>2,
:active_for_action=>{'admin/property_hires'=>"index"},
:available_for => 'sub_managers'
context_link 'property_hire.order',
:link_path=>"order_admin_property_hires_path" ,
:priority=>2,
:active_for_action=>{'admin/property_hires'=>"order"},
:available_for => 'managers'
context_link 'new_',
:link_path=>"new_admin_property_hire_path" ,
:priority=>3,
:active_for_action=>{'admin/property_hires'=>"new"},
:available_for => 'sub_managers'
context_link 'property_hire.manage_locations',
:link_path=>"manage_locations_admin_property_hires_path" ,
:priority=>4,
:active_for_action=>{'admin/property_hires'=>"manage_locations"},
:available_for => 'managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'property_hire').id}",
:priority=>5,
:active_for_action=>{'admin/property_hires'=>'categories'},
:active_for_category => 'PropertyHire',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'property_hire').id}",
:priority=>6,
:active_for_action=>{'admin/property_hires'=>'tags'},
:active_for_tag => 'PropertyHire',
:available_for => 'managers'
context_link 'property_hire.settings',
:link_path=>"settings_admin_property_hires_path" ,
:priority=>7,
:active_for_action=>{'admin/property_hires'=>'settings'},
:available_for => 'managers'
end
end
end
end
end