Skip to content

Commit

Permalink
Merge branch 'devel-1.5.3'
Browse files Browse the repository at this point in the history
Conflicts:
	config/locales/pt-BR.yml
  • Loading branch information
picman committed Aug 10, 2015
2 parents 82d489a + bee3f17 commit 544acbf
Show file tree
Hide file tree
Showing 150 changed files with 20,676 additions and 8,254 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog for Redmine DMSF
==========================

1.5.3 *2015-08-10*
------------------

Plupload 2.1.8
Redmine >= 3.0 required

* Bug: #430 - Got 500 error when change directory name
* Bug: #427 - Can't access to WebDAV root directory
* Bug: #422 - Document uploading in IE

1.5.2 *2015-07-13*
------------------

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Redmine DMSF Plugin
===================

The current version of Redmine DMSF is **1.5.2** [![Build Status](https://api.travis-ci.org/danmunn/redmine_dmsf.png)](https://travis-ci.org/danmunn/redmine_dmsf)
The current version of Redmine DMSF is **1.5.3** [![Build Status](https://api.travis-ci.org/danmunn/redmine_dmsf.png)](https://travis-ci.org/danmunn/redmine_dmsf)

Redmine DMSF is Document Management System Features plugin for Redmine issue tracking system; It is aimed to replace current Redmine's Documents module.

Expand Down Expand Up @@ -42,7 +42,7 @@ Features
Dependencies
------------

* Redmine 2.5.0 or higher
* Redmine 3.0.0 or higher

### Fulltext search (optional)

Expand Down Expand Up @@ -140,7 +140,7 @@ In the file <redmine_root>/public/help/<language>/wiki_syntax_detailed.html, aft
In the file <redmine_root>/public/help/<language>/wiki_syntax.html, at the end of the Redmine links section:
<tr><th></th><td>{{dmsf(83)}}</td><td>Document <a href="#">#83</a></td></tr>
<tr><th></th><td>{{dmsf(83)}}</td><td>Document <a href="#">#83</a></td></tr>
There's a patch that helps you to modify all help files at once. In your Redmine folder:
Expand Down Expand Up @@ -218,4 +218,4 @@ Changes with tests, and full documentation are preferred.
Additional Documentation
------------------------
[CHANGELOG.md](CHANGELOG.md) - Project changelog
[CHANGELOG.md](CHANGELOG.md) - Project changelog
5 changes: 3 additions & 2 deletions app/controllers/dmsf_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ def save
redirect_to dmsf_folder_path(:id => @project, :folder_id => @folder)
return
end
@pathfolder = copy_folder(@folder)
@folder.attributes = params[:dmsf_folder]
@pathfolder = copy_folder(@folder)
@folder.title = params[:dmsf_folder][:title]
@folder.description = params[:dmsf_folder][:description]

# Custom fields
if params[:dmsf_folder][:custom_field_values].present?
Expand Down
19 changes: 10 additions & 9 deletions app/controllers/dmsf_workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def new_action
file = DmsfFile.joins(:revisions).where(:dmsf_file_revisions => {:id => revision.id}).first
if file
begin
file.unlock!
file.unlock! true
rescue DmsfLockError => e
logger.warn e.message
flash[:info] = e.message
#logger.warn e.message
end
end
if revision.workflow == DmsfWorkflow::STATE_APPROVED
Expand Down Expand Up @@ -287,18 +288,18 @@ def add_step
step = params[:step].to_i
end
operator = (params[:commit] == l(:dmsf_and)) ? DmsfWorkflowStep::OPERATOR_AND : DmsfWorkflowStep::OPERATOR_OR
users = User.where(:id => params[:user_ids])
users = User.where(:id => params[:user_ids]).to_a
if users.count > 0
users.each do |user|
ws = DmsfWorkflowStep.new(
:dmsf_workflow_id => @dmsf_workflow.id,
:step => step,
:user_id => user.id,
:operator => operator)
ws = DmsfWorkflowStep.new
ws.dmsf_workflow_id = @dmsf_workflow.id
ws.step = step
ws.user_id = user.id
ws.operator = operator
if ws.save
@dmsf_workflow.dmsf_workflow_steps << ws
else
flash[:error] = @dmsf_workflow.errors.full_messages.to_sentence
flash[:error] = ws.errors.full_messages.to_sentence
end
end
else
Expand Down
73 changes: 20 additions & 53 deletions app/models/dmsf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,15 @@ class DmsfFile < ActiveRecord::Base
belongs_to :project
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 (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
has_many :locks, -> { where(entity_type: 0).order("#{DmsfLock.table_name}.updated_at DESC") },
:class_name => 'DmsfLock', :foreign_key => 'entity_id', :dependent => :destroy
has_many :referenced_links, -> { where target_type: DmsfFile.model_name.to_s},
:class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy
accepts_nested_attributes_for :revisions, :locks, :referenced_links, :project
else
has_many :revisions, :class_name => 'DmsfFileRevision', :foreign_key => 'dmsf_file_id',
:order => "#{DmsfFileRevision.table_name}.major_version DESC, #{DmsfFileRevision.table_name}.minor_version DESC, #{DmsfFileRevision.table_name}.updated_at DESC",
:dependent => :destroy
has_many :locks, :class_name => 'DmsfLock', :foreign_key => 'entity_id',
:order => "#{DmsfLock.table_name}.updated_at DESC",
:conditions => {:entity_type => 0},
:dependent => :destroy
has_many :referenced_links, :class_name => 'DmsfLink', :foreign_key => 'target_id',
:conditions => {:target_type => DmsfFile.model_name.to_s}, :dependent => :destroy
end

if (Rails::VERSION::MAJOR > 3)
accepts_nested_attributes_for :revisions, :locks, :referenced_links
end

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
has_many :locks, -> { where(entity_type: 0).order("#{DmsfLock.table_name}.updated_at DESC") },
:class_name => 'DmsfLock', :foreign_key => 'entity_id', :dependent => :destroy
has_many :referenced_links, -> { where target_type: DmsfFile.model_name.to_s},
:class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy
accepts_nested_attributes_for :revisions, :locks, :referenced_links, :project

scope :visible, lambda { |*args|
where(deleted: false)
Expand All @@ -78,31 +62,18 @@ def validates_name_uniqueness
existing_file = DmsfFile.visible.find_file_by_name(self.project, self.folder, self.name)
errors.add(:name, l('activerecord.errors.messages.taken')) unless
existing_file.nil? || existing_file.id == self.id
end

if (Rails::VERSION::MAJOR <= 3)
attr_accessor :event_description
end
end

acts_as_event :title => Proc.new { |o| o.name },
:description => Proc.new { |o|
if (Rails::VERSION::MAJOR > 3)
desc = Redmine::Search.cache_store.fetch("DmsfFile-#{o.id}")
if desc
Redmine::Search.cache_store.delete("DmsfFile-#{o.id}")
else
desc = o.description
desc += ' / ' if o.description.present? && o.last_revision.comment.present?
desc += o.last_revision.comment if o.last_revision.comment.present?
end
:description => Proc.new { |o|
desc = Redmine::Search.cache_store.fetch("DmsfFile-#{o.id}")
if desc
Redmine::Search.cache_store.delete("DmsfFile-#{o.id}")
else
desc = o.event_description
unless desc.present?
desc = o.description
desc += ' / ' if o.description.present? && o.last_revision.comment.present?
desc += o.last_revision.comment if o.last_revision.comment.present?
end
end
desc = o.description
desc += ' / ' if o.description.present? && o.last_revision.comment.present?
desc += o.last_revision.comment if o.last_revision.comment.present?
end
desc
},
:url => Proc.new { |o| {:controller => 'dmsf_files', :action => 'show', :id => o} },
Expand Down Expand Up @@ -404,13 +375,9 @@ def self.search(tokens, projects = nil, options = {}, user = User.current)

if dmsf_file
if user.allowed_to?(:view_dmsf_files, dmsf_file.project) &&
(project_ids.blank? || (project_ids.include?(dmsf_file.project.id)))
if (Rails::VERSION::MAJOR > 3)
(project_ids.blank? || (project_ids.include?(dmsf_file.project.id)))
Redmine::Search.cache_store.write("DmsfFile-#{dmsf_file.id}",
dochash['sample'].force_encoding('UTF-8')) if dochash['sample']
else
dmsf_file.event_description = dochash['sample'].force_encoding('UTF-8') if dochash['sample']
end
dochash['sample'].force_encoding('UTF-8')) if dochash['sample']
break if(!options[:limit].blank? && results.count >= options[:limit])
results << dmsf_file
end
Expand Down
47 changes: 14 additions & 33 deletions app/models/dmsf_file_revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,50 +27,31 @@ class DmsfFileRevision < 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'
has_many :access, :class_name => 'DmsfFileRevisionAccess', :foreign_key => 'dmsf_file_revision_id', :dependent => :destroy
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
if (Rails::VERSION::MAJOR > 3)
accepts_nested_attributes_for :access, :dmsf_workflow_step_assignment, :file, :user
end
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
accepts_nested_attributes_for :access, :dmsf_workflow_step_assignment, :file, :user

attr_accessible :file, :title, :name, :description, :comment

# Returns a list of revisions that are not deleted here, or deleted at parent level either
if (Rails::VERSION::MAJOR > 3)
scope :visible, -> { where(deleted: false) }
scope :deleted, -> { where(deleted: true) }
else
scope :visible, where(:deleted => false)
scope :deleted, where(:deleted => true)
end
scope :visible, -> { where(deleted: false) }
scope :deleted, -> { where(deleted: true) }

acts_as_customizable
acts_as_event :title => Proc.new {|o| "#{l(:label_dmsf_updated)}: #{o.file.dmsf_path_str}"},
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o.file}},
:datetime => Proc.new {|o| o.updated_at },
:description => Proc.new {|o| o.comment },
:author => Proc.new {|o| o.user }
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",
:permission => :view_dmsf_file_revisions,
:scope => select("#{DmsfFileRevision.table_name}.*").
joins(
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id").
where("#{DmsfFile.table_name}.deleted = :false", {:false => false})
else
acts_as_activity_provider :type => 'dmsf_file_revisions',
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
:author_key => "#{DmsfFileRevision.table_name}.user_id",
:permission => :view_dmsf_file_revisions,
:find_options => {:select => "#{DmsfFileRevision.table_name}.*",
:joins =>
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id",
:conditions => ["#{DmsfFile.table_name}.deleted = :false", {:false => false}]
}
end

acts_as_activity_provider :type => 'dmsf_file_revisions',
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
:author_key => "#{DmsfFileRevision.table_name}.user_id",
:permission => :view_dmsf_file_revisions,
:scope => select("#{DmsfFileRevision.table_name}.*").
joins(
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id").
where("#{DmsfFile.table_name}.deleted = :false", {:false => false})

validates :title, :name, :presence => true
validates_format_of :name, :with => DmsfFolder.invalid_characters,
Expand Down
41 changes: 13 additions & 28 deletions app/models/dmsf_file_revision_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class DmsfFileRevisionAccess < ActiveRecord::Base
belongs_to :revision, :class_name => 'DmsfFileRevision', :foreign_key => 'dmsf_file_revision_id'
belongs_to :user
delegate :project, :to => :revision, :allow_nil => false
delegate :file, :to => :revision, :allow_nil => false
if (Rails::VERSION::MAJOR > 3)
accepts_nested_attributes_for :user, :revision
end
delegate :file, :to => :revision, :allow_nil => false
accepts_nested_attributes_for :user, :revision

DownloadAction = 0
EmailAction = 1
Expand All @@ -34,29 +32,16 @@ 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 (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",
:permission => :view_dmsf_file_revision_accesses,
:scope => select("#{DmsfFileRevisionAccess.table_name}.*").
joins(
"INNER JOIN #{DmsfFileRevision.table_name} ON #{DmsfFileRevisionAccess.table_name}.dmsf_file_revision_id = #{DmsfFileRevision.table_name}.id " +
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id").
where("#{DmsfFile.table_name}.deleted = :false", {:false => false})
else
acts_as_activity_provider :type => 'dmsf_file_revision_accesses',
:timestamp => "#{DmsfFileRevisionAccess.table_name}.updated_at",
:author_key => "#{DmsfFileRevisionAccess.table_name}.user_id",
:permission => :view_dmsf_file_revision_accesses,
:find_options => {:select => "#{DmsfFileRevisionAccess.table_name}.*",
:joins =>
"INNER JOIN #{DmsfFileRevision.table_name} ON #{DmsfFileRevisionAccess.table_name}.dmsf_file_revision_id = #{DmsfFileRevision.table_name}.id " +
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id",
:conditions => ["#{DmsfFile.table_name}.deleted = :false", {:false => false}]
}
end

acts_as_activity_provider :type => 'dmsf_file_revision_accesses',
:timestamp => "#{DmsfFileRevisionAccess.table_name}.updated_at",
:author_key => "#{DmsfFileRevisionAccess.table_name}.user_id",
:permission => :view_dmsf_file_revision_accesses,
:scope => select("#{DmsfFileRevisionAccess.table_name}.*").
joins(
"INNER JOIN #{DmsfFileRevision.table_name} ON #{DmsfFileRevisionAccess.table_name}.dmsf_file_revision_id = #{DmsfFileRevision.table_name}.id " +
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id").
where("#{DmsfFile.table_name}.deleted = :false", {:false => false})

end
Loading

0 comments on commit 544acbf

Please sign in to comment.