Dynamically load hooks/patches & require redmine4+

This commit is contained in:
2022-03-02 07:15:54 -05:00
parent 218d3392f0
commit 66d393a465

89
init.rb
View File

@@ -8,61 +8,52 @@
# #
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Dynamically load all Hooks & Patches
ActiveSupport::Reloader.to_prepare do
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
next unless /\.rb$/ =~ file
require_dependency file
end
end
Redmine::Plugin.register :redmine_qbo do Redmine::Plugin.register :redmine_qbo do
# View Hook Listeners # About
require_dependency 'issues_form_hook_listener' name 'Redmine Quickbooks Online plugin'
require_dependency 'issues_save_hook_listener' author 'Rick Barrette'
require_dependency 'issues_show_hook_listener' description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues'
require_dependency 'users_show_hook_listener' version '1.1.0'
require_dependency 'header_footer_hook_listener' url 'https://github.com/rickbarrette/redmine_qbo'
require_dependency 'projects_form_hook_listener' author_url 'http://rickbarrette.org'
require_dependency 'view_hook_listener' settings :default => {'empty' => true}, :partial => 'qbo/settings'
requires_redmine :version_or_higher => '4.0.0'
# Patches to the Redmine core. Will not work in development mode # Add safe attributes for core models
require_dependency 'issue_patch' Issue.safe_attributes 'customer_id'
require_dependency 'project_patch' Issue.safe_attributes 'qbo_item_id'
require_dependency 'user_patch' Issue.safe_attributes 'qbo_estimate_id'
require_dependency 'query_patch' Issue.safe_attributes 'qbo_invoice_id'
require_dependency 'time_entry_query_patch' Issue.safe_attributes 'vehicles_id'
require_dependency 'pdf_patch' User.safe_attributes 'qbo_employee_id'
require_dependency 'attachments_controller_patch' TimeEntry.safe_attributes 'qbo_billed'
Project.safe_attributes 'customer_id'
Project.safe_attributes 'vehicle_id'
# About # We are playing in the sandbox
name 'Redmine Quickbooks Online plugin' #Quickbooks.sandbox_mode = true
author 'Rick Barrette'
description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues'
version '1.1.0'
url 'https://github.com/rickbarrette/redmine_qbo'
author_url 'http://rickbarrette.org'
settings :default => {'empty' => true}, :partial => 'qbo/settings'
# Add safe attributes # set per_page globally
Issue.safe_attributes 'customer_id' WillPaginate.per_page = 20
Issue.safe_attributes 'qbo_item_id'
Issue.safe_attributes 'qbo_estimate_id'
Issue.safe_attributes 'qbo_invoice_id'
Issue.safe_attributes 'vehicles_id'
User.safe_attributes 'qbo_employee_id'
TimeEntry.safe_attributes 'qbo_billed'
Project.safe_attributes 'customer_id'
Project.safe_attributes 'vehicle_id'
# We are playing in the sandbox # Permissions for security
#Quickbooks.sandbox_mode = true permission :view_customers, :customers => :index, :public => false
permission :add_customers, :customers => :new, :public => false
permission :view_payments, :payments => :index, :public => false
permission :add_payments, :payments => :new, :public => false
permission :view_vehicles, :payments => :new, :public => false
# set per_page globally # Register top menu items
WillPaginate.per_page = 20 menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?}
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
# Permissions for security
permission :view_customers, :customers => :index, :public => false
permission :add_customers, :customers => :new, :public => false
permission :view_payments, :payments => :index, :public => false
permission :add_payments, :payments => :new, :public => false
permission :view_vehicles, :payments => :new, :public => false
# Register QBO top menu item
menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?}
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
end end