diff --git a/init.rb b/init.rb index a653183..78170f6 100644 --- a/init.rb +++ b/init.rb @@ -1,7 +1,7 @@ require 'redmine' # Hooks -require 'todo_issues_hook' +require_dependency 'todo_issues_hook' # Patches to the Redmine core require 'dispatcher' diff --git a/lib/todo_issues_controller_patch.rb b/lib/todo_issues_controller_patch.rb index 9583054..f85d9df 100644 --- a/lib/todo_issues_controller_patch.rb +++ b/lib/todo_issues_controller_patch.rb @@ -19,7 +19,7 @@ require_dependency 'issues_controller' module TodoIssuesControllerPatch module ClassMethods - def show_with_todo + def set_todos @allowed_to_edit_todos = User.current.allowed_to?(:edit_todos, @project) #find all todos that relate to this issue... but only collect the 'highest' ones, as we dont want to double render. @@ -38,14 +38,10 @@ module TodoIssuesControllerPatch end @todos = @todos.to_a - - #@todos = @project.todos.roots.find(:all, :conditions => ["issue_id = ?", @issue.id]) - show_without_todo - end - def show_todos - render :partial => 'todos', :locals => { :todos => @todos } + #@todos = @project.todos.roots.find(:all, :conditions => ["issue_id = ?", @issue.id]) end + private :set_todos end def self.included(base) # :nodoc: @@ -55,7 +51,7 @@ module TodoIssuesControllerPatch base.class_eval do unloadable # Send unloadable so it will not be unloaded in development helper :todos - alias_method_chain(:show, :todo) unless method_defined?(:show_without_todo) + before_filter :set_todos end end end diff --git a/lib/todo_issues_hook.rb b/lib/todo_issues_hook.rb index c169298..df747b2 100644 --- a/lib/todo_issues_hook.rb +++ b/lib/todo_issues_hook.rb @@ -7,10 +7,7 @@ class TodoIssuesHook < Redmine::Hook::ViewListener # Context: # * :issue => Current issue # - def view_issues_show_description_bottom(context ={ }) - controller = context[:controller] - controller.show_todos - end + render_on :view_issues_show_description_bottom, :partial => 'todos', :locals => { :todos => @todos } def view_layouts_base_html_head(context = {}) project = context[:project]