Project folder names in WebDav can be the project name instead of identifier.
This commit is contained in:
parent
2bbd259ff2
commit
12a7a45e59
@ -93,6 +93,22 @@ module RedmineDmsf
|
||||
new_path = '/' + new_path unless new_path[0,1] == '/'
|
||||
@__proxy.class.new("#{new_public}#{name}", "#{new_path}#{name}", request, response, options.merge(:user => @user))
|
||||
end
|
||||
|
||||
def child_project(p)
|
||||
project_display_name = ProjectResource.create_display_name(p)
|
||||
|
||||
new_public = public_path.dup
|
||||
new_public = new_public + '/' unless new_public[-1,1] == '/'
|
||||
new_public = '/' + new_public unless new_public[0,1] == '/'
|
||||
new_public += project_display_name
|
||||
|
||||
new_path = path.dup
|
||||
new_path = new_path + '/' unless new_path[-1,1] == '/'
|
||||
new_path = '/' + new_path unless new_path[0,1] == '/'
|
||||
new_path += project_display_name
|
||||
|
||||
@__proxy.class.new("#{new_public}", "#{new_path}", request, response, options.merge(:user => @user))
|
||||
end
|
||||
|
||||
def parent
|
||||
p = @__proxy.parent
|
||||
@ -148,12 +164,27 @@ module RedmineDmsf
|
||||
# Return instance of Project based on the path
|
||||
def project
|
||||
unless @project
|
||||
use_project_names = Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
||||
pinfo = @path.split('/').drop(1)
|
||||
if pinfo.length > 0
|
||||
begin
|
||||
@project = Project.find(pinfo.first)
|
||||
rescue Exception => e
|
||||
Rails.logger.warn e.message
|
||||
if use_project_names
|
||||
unless pinfo.first.match('(\[([0-9]+)\])$').nil?
|
||||
pid = $2
|
||||
begin
|
||||
@project = Project.find_by_id(pid)
|
||||
rescue Exception => e
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
end
|
||||
if @project.nil?
|
||||
Rails.logger.warn {"WebDAV ERROR: No project found on path '#{@path}'"}
|
||||
end
|
||||
else
|
||||
begin
|
||||
@project = Project.find(pinfo.first)
|
||||
rescue Exception => e
|
||||
Rails.logger.warn e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -31,10 +31,10 @@ module RedmineDmsf
|
||||
def children
|
||||
unless @projects
|
||||
@projects = []
|
||||
Project.select(:identifier).has_module(:dmsf).where(
|
||||
Project.select(:id, :identifier, :name).has_module(:dmsf).where(
|
||||
Project.allowed_to_condition(
|
||||
User.current, :view_dmsf_folders)).order('lft').all.each do |p|
|
||||
@projects << child(p.identifier)
|
||||
@projects << child_project(p)
|
||||
end
|
||||
end
|
||||
@projects
|
||||
|
||||
@ -28,7 +28,7 @@ module RedmineDmsf
|
||||
@children = nil
|
||||
end
|
||||
|
||||
def children
|
||||
def children
|
||||
unless @children
|
||||
@children = []
|
||||
if project
|
||||
@ -72,7 +72,7 @@ module RedmineDmsf
|
||||
end
|
||||
|
||||
def name
|
||||
project.identifier unless project.nil?
|
||||
ProjectResource.create_display_name(project)
|
||||
end
|
||||
|
||||
def long_name
|
||||
@ -108,7 +108,16 @@ module RedmineDmsf
|
||||
def project_id
|
||||
self.project.id if self.project
|
||||
end
|
||||
|
||||
|
||||
def self.create_display_name(p)
|
||||
use_project_names = Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
||||
if use_project_names
|
||||
"#{p.name.gsub(/\W/, "_")} [#{p.id}]" unless p.nil?
|
||||
else
|
||||
p.identifier unless p.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user