Guest User

Untitled

a guest
Jul 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. # Integrate Rails callbacks into existing parts of Redmine
  2.  
  3.  
  4.  
  5. # in init.rb file
  6. # ---------------
  7.  
  8. ~~~ ruby
  9. require 'redmine'
  10.  
  11. # Patches to the Redmine core.
  12. require 'dispatcher'
  13.  
  14. Dispatcher.to_prepare :redmine_kanban do
  15. require_dependency 'issue'
  16. # Guards against including the module multiple time (like in tests)
  17. # and registering multiple callbacks
  18. unless Issue.included_modules.include? RedmineKanban::IssuePatch
  19. Issue.send(:include, RedmineKanban::IsstuePatch)
  20. end
  21. end
  22. ~~~
  23.  
  24.  
  25. # in patch file
  26. # --------------
  27.  
  28. ~~~ ruby
  29. module IssuePatch
  30. def self.included(base) # :nodoc:
  31. base.extend(ClassMethods)
  32.  
  33. base.send(:include, InstanceMethods)
  34.  
  35. # Same as typing in the class
  36. base.class_eval do
  37. unloadable # Send unloadable so it will not be unloaded in development
  38.  
  39. after_save :update_kanban_from_issue
  40. after_destroy :remove_kanban_issues
  41.  
  42. # Add visible to Redmine 0.8.x
  43. unless respond_to?(:visible)
  44. named_scope :visible, lambda {|*args| { :include => :project,
  45. :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
  46. end
  47. end
  48. end
  49. ~~~
Add Comment
Please, Sign In to add comment