From 452edfeeaa479984cec29f05e593a719d564fa12 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 21 Apr 2009 21:44:58 -0700 Subject: [PATCH] Refactored core Redmine patches so the plugin can be run in development. --- app/controllers/rates_controller.rb | 1 + app/models/rate.rb | 1 + init.rb | 11 ++++++++++- lib/rate_sort_helper_patch.rb | 2 +- lib/rate_time_entry_patch.rb | 2 +- lib/rate_users_helper_patch.rb | 2 -- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/rates_controller.rb b/app/controllers/rates_controller.rb index 2f7fbc0..4312ef2 100644 --- a/app/controllers/rates_controller.rb +++ b/app/controllers/rates_controller.rb @@ -1,4 +1,5 @@ class RatesController < ApplicationController + unloadable helper :users helper :sort include SortHelper diff --git a/app/models/rate.rb b/app/models/rate.rb index c5288b1..9343e65 100644 --- a/app/models/rate.rb +++ b/app/models/rate.rb @@ -1,4 +1,5 @@ class Rate < ActiveRecord::Base + unloadable class InvalidParameterException < Exception; end belongs_to :project diff --git a/init.rb b/init.rb index eab5d0a..699be07 100644 --- a/init.rb +++ b/init.rb @@ -1,9 +1,18 @@ require 'redmine' -require 'rate_users_helper_patch' +# Patches to the Redmine core +require 'dispatcher' require 'rate_sort_helper_patch' require 'rate_time_entry_patch' +require 'rate_users_helper_patch' +Dispatcher.to_prepare do + SortHelper.send(:include, RateSortHelperPatch) + TimeEntry.send(:include, RateTimeEntryPatch) + UsersHelper.send(:include, RateUsersHelperPatch) +end + +# Hooks require 'rate_project_hook' Redmine::Plugin.register :redmine_rate do diff --git a/lib/rate_sort_helper_patch.rb b/lib/rate_sort_helper_patch.rb index 39a7545..5f95756 100644 --- a/lib/rate_sort_helper_patch.rb +++ b/lib/rate_sort_helper_patch.rb @@ -103,5 +103,5 @@ module RateSortHelperPatch end end -SortHelper.send(:include, RateSortHelperPatch) + diff --git a/lib/rate_time_entry_patch.rb b/lib/rate_time_entry_patch.rb index 1aa1048..af2c4ac 100644 --- a/lib/rate_time_entry_patch.rb +++ b/lib/rate_time_entry_patch.rb @@ -35,4 +35,4 @@ module RateTimeEntryPatch end end -TimeEntry.send(:include, RateTimeEntryPatch) + diff --git a/lib/rate_users_helper_patch.rb b/lib/rate_users_helper_patch.rb index d25a4de..139d2b3 100644 --- a/lib/rate_users_helper_patch.rb +++ b/lib/rate_users_helper_patch.rb @@ -34,5 +34,3 @@ module RateUsersHelperPatch end end -UsersHelper.send(:include, RateUsersHelperPatch) -