From 183beae595651f4a1996aba39f2af7b3838dd6eb Mon Sep 17 00:00:00 2001 From: Sebastian Schuster Date: Thu, 6 Jun 2013 16:53:45 +0200 Subject: [PATCH 1/3] Removed some unnecessary requires and moved widgets around so they can be autoloaded by rails --- app/models/cost_query.rb | 2 -- app/models/cost_query/filter/base.rb | 1 + app/models/cost_query/filter/status_id.rb | 2 ++ app/models/cost_query/group_by/base.rb | 1 + app/models/entry.rb | 3 --- app/views/cost_reports/index.html.erb | 1 - lib/open_project/reporting/engine.rb | 9 --------- .../reporting/widgets => widget}/cost_types.rb | 0 .../reporting/widgets => widget}/entry_table.rb | 2 -- .../widgets/settings.rb => widget/settings_patch.rb} | 0 .../reporting/widgets => widget}/simple_table.rb | 2 -- .../reporting/widgets => widget}/sortable_init.rb | 0 12 files changed, 4 insertions(+), 19 deletions(-) create mode 100644 app/models/cost_query/filter/base.rb create mode 100644 app/models/cost_query/group_by/base.rb rename lib/{open_project/reporting/widgets => widget}/cost_types.rb (100%) rename lib/{open_project/reporting/widgets => widget}/entry_table.rb (98%) rename lib/{open_project/reporting/widgets/settings.rb => widget/settings_patch.rb} (100%) rename lib/{open_project/reporting/widgets => widget}/simple_table.rb (97%) rename lib/{open_project/reporting/widgets => widget}/sortable_init.rb (100%) diff --git a/app/models/cost_query.rb b/app/models/cost_query.rb index 566b71f540..ebff6bca53 100644 --- a/app/models/cost_query.rb +++ b/app/models/cost_query.rb @@ -1,5 +1,3 @@ -require 'reporting_engine/report' - class CostQuery < Report def_delegators :result, :real_costs diff --git a/app/models/cost_query/filter/base.rb b/app/models/cost_query/filter/base.rb new file mode 100644 index 0000000000..b02c395710 --- /dev/null +++ b/app/models/cost_query/filter/base.rb @@ -0,0 +1 @@ +class CostQuery::Filter::Base < Report::Filter::Base; end diff --git a/app/models/cost_query/filter/status_id.rb b/app/models/cost_query/filter/status_id.rb index 673ce21bd9..efa13211e1 100644 --- a/app/models/cost_query/filter/status_id.rb +++ b/app/models/cost_query/filter/status_id.rb @@ -1,3 +1,5 @@ +#we have to require this here because the operators would not be defined otherwise +require_dependency 'cost_query/operator' class CostQuery::Filter::StatusId < CostQuery::Filter::Base available_operators 'c', 'o' join_table Issue, IssueStatus => [Issue, :status] diff --git a/app/models/cost_query/group_by/base.rb b/app/models/cost_query/group_by/base.rb new file mode 100644 index 0000000000..6aff1574f1 --- /dev/null +++ b/app/models/cost_query/group_by/base.rb @@ -0,0 +1 @@ +class CostQuery::GroupBy::Base < Report::GroupBy::Base; end diff --git a/app/models/entry.rb b/app/models/entry.rb index 347f309fe6..89bbca5514 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb @@ -1,6 +1,3 @@ -require_dependency "time_entry" -require_dependency "cost_entry" - module Entry [TimeEntry, CostEntry].each { |e| e.send :include, self } diff --git a/app/views/cost_reports/index.html.erb b/app/views/cost_reports/index.html.erb index ae98e44e95..785c240c4f 100644 --- a/app/views/cost_reports/index.html.erb +++ b/app/views/cost_reports/index.html.erb @@ -10,7 +10,6 @@

<%= render_widget Widget::Controls::QueryName, @query, :can_rename => allowed_to?(:rename, @query, current_user) %>

- <%= render_widget Widget::Settings, @query, :cost_types => @cost_types, :selected_type_id => @unit_id %>
diff --git a/lib/open_project/reporting/engine.rb b/lib/open_project/reporting/engine.rb index c4a5e9a488..3768676e41 100644 --- a/lib/open_project/reporting/engine.rb +++ b/lib/open_project/reporting/engine.rb @@ -1,6 +1,3 @@ -require 'openproject_costs' -require 'reporting_engine' - module OpenProject::Reporting class Engine < ::Rails::Engine engine_name :openproject_reporting @@ -38,12 +35,6 @@ module OpenProject::Reporting end config.to_prepare do - require_dependency 'reporting_engine/widget.rb' - require_dependency 'open_project/reporting/widgets/simple_table' - require_dependency 'open_project/reporting/widgets/entry_table' - require_dependency 'open_project/reporting/widgets/cost_types' - require_dependency 'open_project/reporting/widgets/settings' - unless Redmine::Plugin.registered_plugins.include?(:openproject_reporting) Redmine::Plugin.register :openproject_reporting do name 'Reporting Plugin' diff --git a/lib/open_project/reporting/widgets/cost_types.rb b/lib/widget/cost_types.rb similarity index 100% rename from lib/open_project/reporting/widgets/cost_types.rb rename to lib/widget/cost_types.rb diff --git a/lib/open_project/reporting/widgets/entry_table.rb b/lib/widget/entry_table.rb similarity index 98% rename from lib/open_project/reporting/widgets/entry_table.rb rename to lib/widget/entry_table.rb index 6a3240373d..08ec2ff0ce 100644 --- a/lib/open_project/reporting/widgets/entry_table.rb +++ b/lib/widget/entry_table.rb @@ -1,5 +1,3 @@ -require 'open_project/reporting/widgets/sortable_init' - class Widget::Table::EntryTable < Widget::Table Fields = [:spent_on, :user_id, :activity_id, :issue_id, :comments, :project_id] diff --git a/lib/open_project/reporting/widgets/settings.rb b/lib/widget/settings_patch.rb similarity index 100% rename from lib/open_project/reporting/widgets/settings.rb rename to lib/widget/settings_patch.rb diff --git a/lib/open_project/reporting/widgets/simple_table.rb b/lib/widget/simple_table.rb similarity index 97% rename from lib/open_project/reporting/widgets/simple_table.rb rename to lib/widget/simple_table.rb index ae60d39dd2..3645fb9d8f 100644 --- a/lib/open_project/reporting/widgets/simple_table.rb +++ b/lib/widget/simple_table.rb @@ -1,5 +1,3 @@ -require 'open_project/reporting/widgets/sortable_init' - class Widget::Table::SimpleTable < Widget::Table simple_table self diff --git a/lib/open_project/reporting/widgets/sortable_init.rb b/lib/widget/sortable_init.rb similarity index 100% rename from lib/open_project/reporting/widgets/sortable_init.rb rename to lib/widget/sortable_init.rb From fd74ecabf7c05a7a9aced5cae94e34a6a068aabb Mon Sep 17 00:00:00 2001 From: Sebastian Schuster Date: Thu, 6 Jun 2013 17:10:02 +0200 Subject: [PATCH 2/3] Added correct requires for monkeypatching to work --- lib/open_project/reporting/engine.rb | 1 + lib/widget/settings_patch.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/open_project/reporting/engine.rb b/lib/open_project/reporting/engine.rb index 3768676e41..7f11616fda 100644 --- a/lib/open_project/reporting/engine.rb +++ b/lib/open_project/reporting/engine.rb @@ -35,6 +35,7 @@ module OpenProject::Reporting end config.to_prepare do + require_dependency 'widget/settings_patch' unless Redmine::Plugin.registered_plugins.include?(:openproject_reporting) Redmine::Plugin.register :openproject_reporting do name 'Reporting Plugin' diff --git a/lib/widget/settings_patch.rb b/lib/widget/settings_patch.rb index 5d5e4b5396..7974897b95 100644 --- a/lib/widget/settings_patch.rb +++ b/lib/widget/settings_patch.rb @@ -1,4 +1,9 @@ +#explicitly require what will be patched to be loaded from the ReportingEngine +require_dependency 'widget/settings' class Widget::Settings < Widget::Base + #make sure this patch gets unloaded as it does not fit + #the standard rails path + unloadable @@settings_to_render.insert -2, :cost_types From 53416e72a6ac5247519d5d467ed4825ee727601e Mon Sep 17 00:00:00 2001 From: Sebastian Schuster Date: Thu, 6 Jun 2013 18:10:18 +0200 Subject: [PATCH 3/3] Also required the walker and transformer because we dont implement both ourselves so CostQuery::Walker would lead to an undefined constant instead of silently loading Report::Walker which is the intended behavior here --- lib/open_project/reporting/engine.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/open_project/reporting/engine.rb b/lib/open_project/reporting/engine.rb index 7f11616fda..c5f4a76333 100644 --- a/lib/open_project/reporting/engine.rb +++ b/lib/open_project/reporting/engine.rb @@ -35,6 +35,8 @@ module OpenProject::Reporting end config.to_prepare do + require_dependency 'report/walker' + require_dependency 'report/transformer' require_dependency 'widget/settings_patch' unless Redmine::Plugin.registered_plugins.include?(:openproject_reporting) Redmine::Plugin.register :openproject_reporting do