#1290 formatted title
This commit is contained in:
parent
45fdd94fb4
commit
b15c3eef10
@ -62,15 +62,10 @@ class DmsfFilesController < ApplicationController
|
||||
access.action = DmsfFileRevisionAccess::DownloadAction
|
||||
access.save!
|
||||
member = Member.find_by(user_id: User.current.id, project_id: @file.project.id)
|
||||
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
|
||||
title_format = member.dmsf_title_format
|
||||
else
|
||||
title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format']
|
||||
end
|
||||
# IE has got a tendency to cache files
|
||||
expires_in(0.year, 'must-revalidate' => true)
|
||||
send_file @revision.disk_file,
|
||||
filename: filename_for_content_disposition(@revision.formatted_name(title_format)),
|
||||
filename: filename_for_content_disposition(@revision.formatted_name(member)),
|
||||
type: @revision.detect_content_type,
|
||||
disposition: params[:disposition].present? ? params[:disposition] : @revision.dmsf_file.disposition
|
||||
rescue DmsfAccessError => e
|
||||
|
||||
@ -154,7 +154,10 @@ module DmsfQueriesHelper
|
||||
tag = "<span class=\"dmsf-expander\"></span>".html_safe + tag
|
||||
end
|
||||
end
|
||||
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
|
||||
member = Member.find_by(user_id: User.current.id, project_id: item.project_id)
|
||||
revision = DmsfFileRevision.find_by(id: item.customized_id)
|
||||
filename = revision ? revision.formatted_name(member) : item.filename
|
||||
tag + content_tag('div', filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
|
||||
when 'url-link'
|
||||
if item&.deleted?
|
||||
tag = content_tag('span', value, class: 'icon dmsf-icon-link')
|
||||
|
||||
@ -453,12 +453,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
|
||||
def display_name
|
||||
member = Member.find_by(user_id: User.current.id, project_id: project_id)
|
||||
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
|
||||
title_format = member.dmsf_title_format
|
||||
else
|
||||
title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format']
|
||||
end
|
||||
fname = formatted_name(title_format)
|
||||
fname = formatted_name(member)
|
||||
if fname.length > 50
|
||||
return "#{fname[0, 25]}...#{fname[-25, 25]}"
|
||||
end
|
||||
@ -511,9 +506,9 @@ class DmsfFile < ActiveRecord::Base
|
||||
result
|
||||
end
|
||||
|
||||
def formatted_name(format)
|
||||
def formatted_name(member)
|
||||
if last_revision
|
||||
last_revision.formatted_name(format)
|
||||
last_revision.formatted_name(member)
|
||||
else
|
||||
name
|
||||
end
|
||||
|
||||
@ -301,7 +301,12 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
parts.size == 2 ? parts[0].to_i * 1000 + parts[1].to_i : 0
|
||||
end
|
||||
|
||||
def formatted_name(format)
|
||||
def formatted_name(member)
|
||||
if member&.dmsf_title_format.present?
|
||||
format = member.dmsf_title_format
|
||||
else
|
||||
format = Setting.plugin_redmine_dmsf['dmsf_global_title_format']
|
||||
end
|
||||
return name if format.blank?
|
||||
if name =~ /(.*)(\..*)$/
|
||||
filename = $1
|
||||
|
||||
@ -52,11 +52,7 @@ module RedmineDmsf
|
||||
end
|
||||
string_path = file.dmsf_folder.nil? ? '' : (file.dmsf_folder.dmsf_path_str + File::SEPARATOR)
|
||||
string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path
|
||||
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
|
||||
string_path += file.formatted_name(member.dmsf_title_format)
|
||||
else
|
||||
string_path += file.formatted_name(Setting.plugin_redmine_dmsf['dmsf_global_title_format'])
|
||||
end
|
||||
string_path += file.formatted_name(member)
|
||||
zip_entry = ::Zip::Entry.new(@zip_file, string_path, nil, nil, nil, nil, nil, nil,
|
||||
::Zip::DOSTime.at(file.last_revision.updated_at))
|
||||
@zip_file.put_next_entry(zip_entry)
|
||||
@ -84,5 +80,5 @@ module RedmineDmsf
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user