diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 574487dc..9877bc64 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -227,7 +227,7 @@ class DmsfController < ApplicationController end def entries_email - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) @email_params = e_params else @email_params = params[:email] @@ -251,7 +251,7 @@ class DmsfController < ApplicationController end def create - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) @folder = DmsfFolder.new( params.require(:dmsf_folder).permit(:title, :description, :dmsf_folder_id)) else diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 42fdbf1b..ede478ee 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -100,7 +100,7 @@ class DmsfFilesController < ApplicationController if @file.locked_for_user? flash[:error] = l(:error_file_is_locked) else - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) aparams = frev_params else aparams = params diff --git a/app/controllers/dmsf_links_controller.rb b/app/controllers/dmsf_links_controller.rb index 55d8c263..c960128b 100644 --- a/app/controllers/dmsf_links_controller.rb +++ b/app/controllers/dmsf_links_controller.rb @@ -25,7 +25,7 @@ class DmsfLinksController < ApplicationController before_filter :authorize def new - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) @dmsf_link = DmsfLink.new(l_params) else @dmsf_link = DmsfLink.new(:project_id => params[:project_id]) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 6fcbddba..0c531d1e 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -52,7 +52,7 @@ class DmsfUploadController < ApplicationController # async single file upload handling def upload_file - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) @tempfile = params.require(:file) else @tempfile = params[:file] @@ -86,7 +86,7 @@ class DmsfUploadController < ApplicationController end def commit_files - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) commited_files = params.require(:commited_files) else commited_files = params[:commited_files] diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 0f16dafc..062254b2 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -36,7 +36,7 @@ class DmsfFile < ActiveRecord::Base belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id' belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id' - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) has_many :revisions, -> { order("#{DmsfFileRevision.table_name}.major_version DESC, #{DmsfFileRevision.table_name}.minor_version DESC, #{DmsfFileRevision.table_name}.updated_at DESC") }, :class_name => 'DmsfFileRevision', :foreign_key => 'dmsf_file_id', :dependent => :destroy @@ -57,11 +57,11 @@ class DmsfFile < ActiveRecord::Base :conditions => {:target_type => DmsfFile.model_name}, :dependent => :destroy end - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) accepts_nested_attributes_for :revisions, :locks, :referenced_links end - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) scope :visible, -> { where(deleted: false) } scope :deleted, -> { where(deleted: true) } else diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index e1ab603e..cfff5f74 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -26,13 +26,13 @@ class DmsfFileRevision < ActiveRecord::Base belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id' has_many :access, :class_name => 'DmsfFileRevisionAccess', :foreign_key => 'dmsf_file_revision_id', :dependent => :destroy has_many :dmsf_workflow_step_assignment, :dependent => :destroy - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) accepts_nested_attributes_for :access, :dmsf_workflow_step_assignment, :file, :user end # Returns a list of revisions that are not deleted here, or deleted at parent level either - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) scope :visible, -> { where(deleted: false) } scope :deleted, -> { where(deleted: true) } else @@ -46,7 +46,7 @@ class DmsfFileRevision < ActiveRecord::Base :datetime => Proc.new {|o| o.updated_at }, :description => Proc.new {|o| o.comment }, :author => Proc.new {|o| o.user } - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) acts_as_activity_provider :type => 'dmsf_file_revisions', :timestamp => "#{DmsfFileRevision.table_name}.updated_at", :author_key => "#{DmsfFileRevision.table_name}.user_id", diff --git a/app/models/dmsf_file_revision_access.rb b/app/models/dmsf_file_revision_access.rb index 4a7859a4..6c32dd97 100644 --- a/app/models/dmsf_file_revision_access.rb +++ b/app/models/dmsf_file_revision_access.rb @@ -22,7 +22,7 @@ class DmsfFileRevisionAccess < ActiveRecord::Base belongs_to :user delegate :project, :to => :revision, :allow_nil => false delegate :file, :to => :revision, :allow_nil => false - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) accepts_nested_attributes_for :user, :revision end @@ -34,7 +34,7 @@ class DmsfFileRevisionAccess < ActiveRecord::Base :datetime => Proc.new {|o| o.updated_at }, :description => Proc.new {|o| o.revision.comment }, :author => Proc.new {|o| o.user } - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) acts_as_activity_provider :type => 'dmsf_file_revision_accesses', :timestamp => "#{DmsfFileRevisionAccess.table_name}.updated_at", :author_key => "#{DmsfFileRevisionAccess.table_name}.user_id", diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 89e12fa4..6af3f809 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -34,7 +34,7 @@ class DmsfFolder < ActiveRecord::Base :dependent => :destroy has_many :files, :class_name => 'DmsfFile', :foreign_key => 'dmsf_folder_id', :dependent => :destroy - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) has_many :folder_links, -> { where target_type: DmsfFolder.model_name }, :class_name => 'DmsfLink', :foreign_key => 'dmsf_folder_id', :dependent => :destroy has_many :file_links, -> { where target_type: DmsfFile.model_name }, @@ -61,7 +61,7 @@ class DmsfFolder < ActiveRecord::Base :dependent => :destroy end - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) scope :visible, -> { where(deleted: false) } scope :deleted, -> { where(deleted: true) } else diff --git a/app/models/dmsf_link.rb b/app/models/dmsf_link.rb index 0e7f9e36..dc49d6e1 100644 --- a/app/models/dmsf_link.rb +++ b/app/models/dmsf_link.rb @@ -40,7 +40,7 @@ class DmsfLink < ActiveRecord::Base end end - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) scope :visible, -> { where(deleted: false) } scope :deleted, -> { where(deleted: true) } else diff --git a/app/models/dmsf_workflow.rb b/app/models/dmsf_workflow.rb index 8ec83d9c..625da0ce 100644 --- a/app/models/dmsf_workflow.rb +++ b/app/models/dmsf_workflow.rb @@ -19,7 +19,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class DmsfWorkflow < ActiveRecord::Base - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) has_many :dmsf_workflow_steps, -> { order 'step ASC, operator DESC' }, :dependent => :destroy else has_many :dmsf_workflow_steps, :dependent => :destroy, :order => 'step ASC, operator DESC' diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 15efdb59..086b76e4 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -32,7 +32,7 @@ module RedmineDmsf unloadable alias_method_chain :copy, :dmsf - if (Redmine::VERSION::MAJOR >= 3) + if (Rails::VERSION::MAJOR > 3) has_many :dmsf_files, -> { where dmsf_folder_id: nil}, :class_name => 'DmsfFile', :foreign_key => 'project_id', :dependent => :destroy has_many :dmsf_folders, -> {where dmsf_folder_id: nil},