changeset 454:2f1a308c4c11 feature_36

Created the Projects - Publications relationship.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 13 Jun 2011 16:46:17 +0100
parents 2daa350e1da2
children 9761ee24f31d
files vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/init.rb vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb
diffstat 3 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Mon Jun 13 16:12:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Mon Jun 13 16:46:17 2011 +0100
@@ -12,7 +12,9 @@
 
   accepts_nested_attributes_for :authorships
   accepts_nested_attributes_for :authors, :allow_destroy => true
-  accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true 
+  accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true
+  
+  has_and_belongs_to_many :projects
   
   attr_writer :current_step
 
--- a/vendor/plugins/redmine_bibliography/init.rb	Mon Jun 13 16:12:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/init.rb	Mon Jun 13 16:46:17 2011 +0100
@@ -1,4 +1,16 @@
 require 'redmine'
+require 'dispatcher'
+
+
+# Patches to the Redmine core.
+
+Dispatcher.to_prepare :redmine_model_dependencies do
+  require_dependency 'project'
+
+  unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch
+    Project.send(:include, Bibliography::ProjectPublicationsPatch)
+  end
+end
 
 Redmine::Plugin.register :redmine_bibliography do
   name 'Redmine Bibliography plugin'
@@ -11,6 +23,12 @@
   permission :view_bibliography, :redmine_bibliography => :index
 
   menu :project_menu, :redmine_bibliography, {:controller  => 'publications', :action => 'index'}, :caption  => 'Bibliography', :after => :activity, :param => :project_id
-  
+
+
+
+
+
+
 end
 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb	Mon Jun 13 16:46:17 2011 +0100
@@ -0,0 +1,11 @@
+require_dependency 'project'
+
+module Bibliography
+  module ProjectPublicationsPatch
+    def self.included(base)
+          base.class_eval do
+            has_and_belongs_to_many :publications
+          end
+        end
+  end #ProjectPublicationsPatch
+end #RedmineBibliography
\ No newline at end of file