changeset 730:4a9bb3b8d5cd feature_14

Patching the projects controller in order to have access to the params hash before saving (new, update actions) the project model.
author Luis Figueira <luis.figueira@eecs.qmul.ac.uk>
date Mon, 31 Oct 2011 17:11:00 +0000
parents 291c4d7dc0b6
children 3f87a3b61d9c
files vendor/plugins/redmine_tags/init.rb vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb
diffstat 3 files changed, 48 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/init.rb	Thu Oct 27 19:17:17 2011 +0100
+++ b/vendor/plugins/redmine_tags/init.rb	Mon Oct 31 17:11:00 2011 +0000
@@ -53,6 +53,10 @@
     IssuesHelper.send(:include, RedmineTags::Patches::IssuesHelperPatch)
   end
 
+  unless ProjectsController.included_modules.include?(RedmineTags::Patches::ProjectsControllerPatch)
+    ProjectsController.send(:include, RedmineTags::Patches::ProjectsControllerPatch)
+  end
+
   unless AutoCompletesController.included_modules.include?(RedmineTags::Patches::AutoCompletesControllerPatch)
     AutoCompletesController.send(:include, RedmineTags::Patches::AutoCompletesControllerPatch)
   end
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb	Thu Oct 27 19:17:17 2011 +0100
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb	Mon Oct 31 17:11:00 2011 +0000
@@ -7,18 +7,27 @@
     module ProjectPatch
       def self.included(base) # :nodoc:
         base.extend(ClassMethods)
+        base.send(:include, InstanceMethods)
 
         base.class_eval do
           unloadable
+
+          attr_accessor :tag_list
+
           acts_as_taggable
-          alias_method_chain :before_save, :save_tags
+
         end
       end
 
-      def before_save_with_save_tags(context={})
+      def before_save_with_save_tags()
+#        debugger
+        logger.error { "GONNA SAVE TAG LIST" }
 
-        logger.error { "GONNA SAVE TAG LIST" }
-        logger.error { @project.name }
+
+#        params[:tag_list]
+        
+        
+        # logger.error { @project.name }
 
     #    if params && params[:project] && !params[:project][:tag_list].nil?
     #      old_tags = context[:project].tag_list.to_s
@@ -34,7 +43,9 @@
     #    end
       end
       
-
+      module InstanceMethods
+        
+      end
 
       module ClassMethods
         # Returns available issue tags
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Mon Oct 31 17:11:00 2011 +0000
@@ -0,0 +1,28 @@
+require_dependency 'projects_controller'
+
+module RedmineTags
+  module Patches
+    module ProjectsControllerPatch
+      def self.included(base)
+        base.send(:include, InstanceMethods)
+        base.class_eval do          
+          unloadable 
+          before_filter :add_tags_to_project, :only => [:save, :update]
+        end
+      end
+
+      module InstanceMethods
+          
+        
+        def add_tags_to_project
+#          debugger
+          logger.error { "TAG_LIST-->#{params[:project][:tag_list]}" }
+        end
+      end
+    end
+  end
+end
+
+
+
+