This commit is contained in:
parent
0e1b820599
commit
dd3ff7cde9
@ -64,9 +64,7 @@ def init
|
||||
end
|
||||
end
|
||||
|
||||
unless Redmine::Plugin.installed?(:easy_extensions)
|
||||
init
|
||||
else
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
ActiveSupport.on_load(:easyproject, yield: true) do
|
||||
init
|
||||
|
||||
@ -76,6 +74,8 @@ else
|
||||
EpmDmsfLockedDocuments.register_to_scope(:user, :plugin => :redmine_dmsf)
|
||||
EpmDmsfOpenApprovals.register_to_scope(:user, :plugin => :redmine_dmsf)
|
||||
end
|
||||
else
|
||||
init
|
||||
end
|
||||
|
||||
ActionDispatch::Reloader.to_prepare do
|
||||
|
||||
@ -54,11 +54,11 @@ class DmsfContextMenusController < ApplicationController
|
||||
selected_files = params[:ids].select{ |x| x =~ /file-\d+/ }.map{ |x| $1.to_i if x =~ /file-(\d+)/ }
|
||||
selected_file_links = params[:ids].select{ |x| x =~ /file-link-\d+/ }.map{ |x| $1.to_i if x =~ /file-link-(\d+)/ }
|
||||
selected_file_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id.to_s)
|
||||
target_id = DmsfLink.find_by(id: id).pluck(:target_id).first
|
||||
selected_files << target_id if target_id && !selected_files.include?(target_id)
|
||||
end
|
||||
if (selected_files.size == 1) && (params[:ids].size == 1)
|
||||
@file = DmsfFile.find selected_files[0]
|
||||
@file = DmsfFile.find_by(id: selected_files[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -66,7 +66,7 @@ class DmsfController < ApplicationController
|
||||
format.csv {
|
||||
filename = @project.name
|
||||
filename << "_#{@folder.title}" if @folder
|
||||
filename << DateTime.now.strftime('_%Y%m%d%H%M%S.csv')
|
||||
filename << DateTime.current.strftime('_%Y%m%d%H%M%S.csv')
|
||||
send_data(DmsfHelper.dmsf_to_csv(@folder ? @folder : @project, params[:settings][:dmsf_columns]),
|
||||
:type => 'text/csv; header=present', :filename => filename)
|
||||
}
|
||||
@ -77,11 +77,11 @@ class DmsfController < ApplicationController
|
||||
@folder_manipulation_allowed = User.current.allowed_to? :folder_manipulation, @project
|
||||
@file_manipulation_allowed = User.current.allowed_to? :file_manipulation, @project
|
||||
@file_delete_allowed = User.current.allowed_to? :file_delete, @project
|
||||
@subfolders = DmsfFolder.deleted.where(:project_id => @project.id)
|
||||
@files = DmsfFile.deleted.where(:project_id => @project.id)
|
||||
@dir_links = DmsfLink.deleted.where(:project_id => @project.id, :target_type => DmsfFolder.model_name.to_s)
|
||||
@file_links = DmsfLink.deleted.where(:project_id => @project.id, :target_type => DmsfFile.model_name.to_s)
|
||||
@url_links = DmsfLink.deleted.where(:project_id => @project.id, :target_type => 'DmsfUrl')
|
||||
@subfolders = DmsfFolder.deleted.where(project_id: @project.id)
|
||||
@files = DmsfFile.deleted.where(project_id: @project.id)
|
||||
@dir_links = DmsfLink.deleted.where(project_id: @project.id, target_type: DmsfFolder.model_name.to_s)
|
||||
@file_links = DmsfLink.deleted.where(project_id: @project.id, target_type: DmsfFile.model_name.to_s)
|
||||
@url_links = DmsfLink.deleted.where(project_id: @project.id, target_type: 'DmsfUrl')
|
||||
end
|
||||
|
||||
def download_email_entries
|
||||
@ -123,16 +123,16 @@ class DmsfController < ApplicationController
|
||||
if selected_dir_links.present? &&
|
||||
(params[:email_entries].present? || params[:download_entries].present?)
|
||||
selected_dir_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_folders << link.target_id if link && !selected_folders.include?(link.target_id)
|
||||
target_id = DmsfLink.find_by(id: id).pluck(:target_id).first
|
||||
selected_folders << target_id if target_id && !selected_folders.include?(target_id)
|
||||
end
|
||||
end
|
||||
|
||||
if selected_file_links.present? &&
|
||||
(params[:email_entries].present? || params[:download_entries].present?)
|
||||
selected_file_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id)
|
||||
target_id = DmsfLink.find_by(id: id).pluck(:target_id).first
|
||||
selected_files << target_id if target_id && !selected_files.include?(target_id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -178,7 +178,7 @@ class DmsfController < ApplicationController
|
||||
if params[:email][:to].strip.blank?
|
||||
flash[:error] = l(:error_email_to_must_be_entered)
|
||||
else
|
||||
DmsfMailer.send_documents(@project, User.current, params[:email]).deliver
|
||||
DmsfMailer.send_documents(@project, params[:email]).deliver
|
||||
File.delete(params[:email][:zipped_content])
|
||||
flash[:notice] = l(:notice_email_sent, params[:email][:to])
|
||||
end
|
||||
@ -195,7 +195,7 @@ class DmsfController < ApplicationController
|
||||
@parent = @folder.dmsf_folder
|
||||
@pathfolder = copy_folder(@folder)
|
||||
@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project)
|
||||
@users = Principal.active.where(:id => @folder.dmsf_folder_permissions.users.map{ |p| p.object_id })
|
||||
@users = Principal.active.where(id: @folder.dmsf_folder_permissions.users.map{ |p| p.object_id })
|
||||
end
|
||||
|
||||
def create
|
||||
@ -292,14 +292,14 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def notify_activate
|
||||
if((@folder && @folder.notification) || (@folder.nil? && @project.dmsf_notification))
|
||||
if (@folder && @folder.notification) || (@folder.nil? && @project.dmsf_notification)
|
||||
flash[:warning] = l(:warning_folder_notifications_already_activated)
|
||||
else
|
||||
if @folder
|
||||
@folder.notify_activate
|
||||
else
|
||||
@project.dmsf_notification = true
|
||||
@project.save
|
||||
@project.save!
|
||||
end
|
||||
flash[:notice] = l(:notice_folder_notifications_activated)
|
||||
end
|
||||
@ -307,14 +307,14 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def notify_deactivate
|
||||
if((@folder && !@folder.notification) || (@folder.nil? && !@project.dmsf_notification))
|
||||
if (@folder && !@folder.notification) || (@folder.nil? && !@project.dmsf_notification)
|
||||
flash[:warning] = l(:warning_folder_notifications_already_deactivated)
|
||||
else
|
||||
if @folder
|
||||
@folder.notify_deactivate
|
||||
else
|
||||
@project.dmsf_notification = nil
|
||||
@project.save
|
||||
@project.save!
|
||||
end
|
||||
flash[:notice] = l(:notice_folder_notifications_deactivated)
|
||||
end
|
||||
@ -354,8 +354,8 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def append_email
|
||||
@principals = Principal.where(:id => params[:user_ids]).to_a
|
||||
head 200 if @principals.blank?
|
||||
@principals = Principal.where(id: params[:user_ids]).to_a
|
||||
head :success if @principals.blank?
|
||||
end
|
||||
|
||||
def autocomplete_for_user
|
||||
@ -424,7 +424,7 @@ class DmsfController < ApplicationController
|
||||
audit.save!
|
||||
end
|
||||
send_file(zip.finish,
|
||||
:filename => filename_for_content_disposition("#{@project.name}-#{DateTime.now.strftime('%y%m%d%H%M%S')}.zip"),
|
||||
:filename => filename_for_content_disposition("#{@project.name}-#{DateTime.current.strftime('%y%m%d%H%M%S')}.zip"),
|
||||
:type => 'application/zip',
|
||||
:disposition => 'attachment')
|
||||
rescue StandardError
|
||||
@ -434,9 +434,9 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def zip_entries(zip, selected_folders, selected_files)
|
||||
member = Member.where(:user_id => User.current.id, :project_id => @project.id).first
|
||||
member = Member.where(user_id: User.current.id, project_id: @project.id).first
|
||||
selected_folders.each do |selected_folder_id|
|
||||
folder = DmsfFolder.visible.find_by_id selected_folder_id
|
||||
folder = DmsfFolder.visible.find_by(id: selected_folder_id)
|
||||
if folder
|
||||
zip.add_folder(folder, member, (folder.dmsf_folder.dmsf_path_str if folder.dmsf_folder))
|
||||
else
|
||||
@ -444,7 +444,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
end
|
||||
selected_files.each do |selected_file_id|
|
||||
file = DmsfFile.visible.find_by_id selected_file_id
|
||||
file = DmsfFile.visible.find_by(id: selected_file_id)
|
||||
unless file && file.last_revision && File.exist?(file.last_revision.disk_file)
|
||||
raise FileNotFound
|
||||
end
|
||||
@ -463,7 +463,7 @@ class DmsfController < ApplicationController
|
||||
def restore_entries(selected_folders, selected_files, selected_dir_links, selected_file_links, selected_url_links)
|
||||
# Folders
|
||||
selected_folders.each do |id|
|
||||
folder = DmsfFolder.find_by_id id
|
||||
folder = DmsfFolder.find_by(id: id)
|
||||
if folder
|
||||
unless folder.restore
|
||||
flash[:error] = folder.errors.full_messages.to_sentence
|
||||
@ -474,7 +474,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
# Files
|
||||
selected_files.each do |id|
|
||||
file = DmsfFile.find_by_id id
|
||||
file = DmsfFile.find_by(id: id)
|
||||
if file
|
||||
unless file.restore
|
||||
flash[:error] = file.errors.full_messages.to_sentence
|
||||
@ -485,7 +485,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
# Links
|
||||
(selected_dir_links + selected_file_links + selected_url_links).each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
link = DmsfLink.find_by(id: id)
|
||||
if link
|
||||
unless link.restore
|
||||
flash[:error] = link.errors.full_messages.to_sentence
|
||||
@ -499,7 +499,7 @@ class DmsfController < ApplicationController
|
||||
def delete_entries(selected_folders, selected_files, selected_dir_links, selected_file_links, selected_url_links, commit)
|
||||
# Folders
|
||||
selected_folders.each do |id|
|
||||
folder = DmsfFolder.find_by_id id
|
||||
folder = DmsfFolder.find_by(id: id)
|
||||
if folder
|
||||
unless folder.delete commit
|
||||
flash[:error] = folder.errors.full_messages.to_sentence
|
||||
@ -513,7 +513,7 @@ class DmsfController < ApplicationController
|
||||
deleted_files = []
|
||||
not_deleted_files = []
|
||||
selected_files.each do |id|
|
||||
file = DmsfFile.find_by_id id
|
||||
file = DmsfFile.find_by(id: id)
|
||||
if file
|
||||
if file.delete(commit)
|
||||
deleted_files << file unless commit
|
||||
@ -525,13 +525,13 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
end
|
||||
# Activities
|
||||
if !deleted_files.empty?
|
||||
unless deleted_files.empty?
|
||||
begin
|
||||
recipients = DmsfMailer.get_notify_users(@project, deleted_files)
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_deleted(u, @project, deleted_files).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
@ -547,7 +547,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
# Links
|
||||
(selected_dir_links + selected_file_links + selected_url_links).each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
link = DmsfLink.find_by(id: id)
|
||||
link.delete commit if link
|
||||
end
|
||||
if flash[:error].blank? && flash[:warning].blank?
|
||||
@ -607,7 +607,7 @@ class DmsfController < ApplicationController
|
||||
if tag
|
||||
@subfolders = []
|
||||
@folder = nil
|
||||
DmsfFolder.where(:project_id => @project.id, :system => false).visible.each do |f|
|
||||
DmsfFolder.where(project_id: @project.id, system: false).visible.find_each do |f|
|
||||
f.custom_field_values.each do |v|
|
||||
if v.custom_field_id == params[:custom_field_id].to_i
|
||||
if v.custom_field.compare_values?(v.value, params[:custom_value])
|
||||
@ -618,7 +618,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
end
|
||||
@files = []
|
||||
DmsfFile.where(:project_id => @project.id).visible.each do |f|
|
||||
DmsfFile.where(project_id: @project.id).visible.find_each do |f|
|
||||
r = f.last_revision
|
||||
if r
|
||||
r.custom_field_values.each do |v|
|
||||
@ -632,8 +632,8 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
end
|
||||
@dir_links = []
|
||||
DmsfLink.where(:project_id => @project.id, :target_type => DmsfFolder.model_name.to_s).where(
|
||||
'target_id IS NOT NULL').visible.each do |l|
|
||||
DmsfLink.where(project_id: @project.id, target_type: DmsfFolder.model_name.to_s).where.not(
|
||||
target_id: nil).visible.find_each do |l|
|
||||
l.target_folder.custom_field_values.each do |v|
|
||||
if v.custom_field_id == params[:custom_field_id].to_i
|
||||
if v.custom_field.compare_values?(v.value, params[:custom_value])
|
||||
@ -644,7 +644,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
end
|
||||
@file_links = []
|
||||
DmsfLink.where(:project_id => @project.id, :target_type => DmsfFile.model_name.to_s).visible.each do |l|
|
||||
DmsfLink.where(project_id: @project.id, target_type: DmsfFile.model_name.to_s).visible.find_each do |l|
|
||||
r = l.target_file.last_revision if l.target_file
|
||||
if r
|
||||
r.custom_field_values.each do |v|
|
||||
@ -692,9 +692,9 @@ class DmsfController < ApplicationController
|
||||
# Trash
|
||||
@trash_visible = @folder_manipulation_allowed && @file_manipulation_allowed &&
|
||||
@file_delete_allowed && !@locked_for_user && !@folder
|
||||
@trash_enabled = DmsfFolder.deleted.where(:project_id => @project.id).any? ||
|
||||
DmsfFile.deleted.where(:project_id => @project.id).any? ||
|
||||
DmsfLink.deleted.where(:project_id => @project.id).any?
|
||||
@trash_enabled = DmsfFolder.deleted.where(project_id: @project.id).exists? ||
|
||||
DmsfFile.deleted.where(project_id: @project.id).exists? ||
|
||||
DmsfLink.deleted.where(project_id: @project.id).exists?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -57,7 +57,7 @@ class DmsfFilesController < ApplicationController
|
||||
access.dmsf_file_revision = @revision
|
||||
access.action = DmsfFileRevisionAccess::DownloadAction
|
||||
access.save!
|
||||
member = Member.where(:user_id => User.current.id, :project_id => @file.project.id).first
|
||||
member = Member.where(user_id: User.current.id, project_id: @file.project.id).first
|
||||
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
|
||||
title_format = member.dmsf_title_format
|
||||
else
|
||||
@ -118,7 +118,15 @@ class DmsfFilesController < ApplicationController
|
||||
revision.increase_version(version)
|
||||
end
|
||||
file_upload = params[:dmsf_attachments]['1'] if params[:dmsf_attachments].present?
|
||||
unless file_upload
|
||||
if file_upload
|
||||
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, file_upload)
|
||||
if upload
|
||||
revision.size = upload.size
|
||||
revision.disk_filename = revision.new_storage_filename
|
||||
revision.mime_type = upload.mime_type
|
||||
revision.digest = DmsfFileRevision.create_digest upload.tempfile_path
|
||||
end
|
||||
else
|
||||
revision.size = last_revision.size
|
||||
revision.disk_filename = last_revision.disk_filename
|
||||
revision.mime_type = last_revision.mime_type
|
||||
@ -127,14 +135,6 @@ class DmsfFilesController < ApplicationController
|
||||
else
|
||||
revision.digest = last_revision.digest
|
||||
end
|
||||
else
|
||||
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, file_upload)
|
||||
if upload
|
||||
revision.size = upload.size
|
||||
revision.disk_filename = revision.new_storage_filename
|
||||
revision.mime_type = upload.mime_type
|
||||
revision.digest = DmsfFileRevision.create_digest upload.tempfile_path
|
||||
end
|
||||
end
|
||||
|
||||
# Custom fields
|
||||
@ -167,7 +167,7 @@ class DmsfFilesController < ApplicationController
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_updated(u, @project, [@file]).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
@ -200,7 +200,7 @@ class DmsfFilesController < ApplicationController
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_deleted(u, @project, [@file]).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
@ -234,7 +234,7 @@ class DmsfFilesController < ApplicationController
|
||||
if @revision.delete(true)
|
||||
if @file.name != @file.last_revision.name
|
||||
@file.name = @file.last_revision.name
|
||||
@file.save
|
||||
@file.save!
|
||||
end
|
||||
flash[:notice] = l(:notice_revision_deleted)
|
||||
else
|
||||
|
||||
@ -59,7 +59,7 @@ class DmsfFilesCopyController < ApplicationController
|
||||
private
|
||||
|
||||
def find_file
|
||||
unless DmsfFile.where(:id => params[:id]).exists?
|
||||
unless DmsfFile.where(id: params[:id]).exists?
|
||||
render_404
|
||||
return
|
||||
end
|
||||
@ -77,7 +77,7 @@ private
|
||||
end
|
||||
if params[:target_folder_id].present?
|
||||
@target_folder = DmsfFolder.visible.find(params[:target_folder_id])
|
||||
unless DmsfFolder.visible.where(:id => params[:target_folder_id]).exists?
|
||||
unless DmsfFolder.visible.where(id: params[:target_folder_id]).exists?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
|
||||
@ -35,8 +35,8 @@ class DmsfFolderPermissionsController < ApplicationController
|
||||
end
|
||||
|
||||
def append
|
||||
@principals = Principal.where(:id => params[:user_ids]).to_a
|
||||
head 200 if @principals.blank?
|
||||
@principals = Principal.where(id: params[:user_ids]).to_a
|
||||
head :success if @principals.blank?
|
||||
end
|
||||
|
||||
def autocomplete_for_user
|
||||
@ -60,7 +60,7 @@ class DmsfFolderPermissionsController < ApplicationController
|
||||
|
||||
def find_folder
|
||||
if params[:dmsf_folder_id]
|
||||
@dmsf_folder = DmsfFolder.visible.find_by_id(params[:dmsf_folder_id])
|
||||
@dmsf_folder = DmsfFolder.visible.find_by(id: params[:dmsf_folder_id])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -48,20 +48,20 @@ class DmsfFoldersCopyController < ApplicationController
|
||||
def move
|
||||
@folder.project = @target_project
|
||||
@folder.dmsf_folder = @target_folder
|
||||
unless @folder.save
|
||||
if @folder.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to dmsf_folder_path(:id => @target_project, :folder_id => @folder)
|
||||
else
|
||||
flash[:error] = @folder.errors.full_messages.join(', ')
|
||||
redirect_to :action => 'new', :id => @folder, :target_project_id => @target_project,
|
||||
:target_folder_id => @target_folder
|
||||
else
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to dmsf_folder_path(:id => @target_project, :folder_id => @folder)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_folder
|
||||
unless DmsfFolder.where(:id => params[:id]).exists?
|
||||
unless DmsfFolder.where(id: params[:id]).exists?
|
||||
render_404
|
||||
return
|
||||
end
|
||||
@ -79,7 +79,7 @@ class DmsfFoldersCopyController < ApplicationController
|
||||
end
|
||||
if params[:target_folder_id].present?
|
||||
@target_folder = DmsfFolder.find(params[:target_folder_id])
|
||||
unless DmsfFolder.visible.where(:id => params[:target_folder_id]).exists?
|
||||
unless DmsfFolder.visible.where(id: params[:target_folder_id]).exists?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
|
||||
@ -56,11 +56,11 @@ class DmsfLinksController < ApplicationController
|
||||
@target_folder_id = params[:dmsf_folder_id].to_i if params[:dmsf_folder_id].present?
|
||||
if @type == 'link_to'
|
||||
if @dmsf_file_id
|
||||
file = DmsfFile.find_by_id @dmsf_file_id
|
||||
@dmsf_link.name = file.title if file
|
||||
names = DmsfFile.where(id: @dmsf_file_id).pluck(:name)
|
||||
@dmsf_link.name = names.first if names.any?
|
||||
else
|
||||
folder = DmsfFolder.find_by_id @target_folder_id
|
||||
@dmsf_link.name = folder.title if folder
|
||||
titles = DmsfFolder.where(id: @target_folder_id).pluck(:title)
|
||||
@dmsf_link.name = titles.first if titles.any?
|
||||
end
|
||||
end
|
||||
@container = params[:container]
|
||||
@ -96,7 +96,7 @@ class DmsfLinksController < ApplicationController
|
||||
@dmsf_link.dmsf_folder_id = nil
|
||||
end
|
||||
@dmsf_link.target_project_id = params[:dmsf_link][:target_project_id]
|
||||
if (params[:external_link] == 'true')
|
||||
if params[:external_link] == 'true'
|
||||
@dmsf_link.external_url = params[:dmsf_link][:external_url]
|
||||
@dmsf_link.target_type = 'DmsfUrl'
|
||||
elsif params[:dmsf_link][:target_file_id].present?
|
||||
@ -121,12 +121,12 @@ class DmsfLinksController < ApplicationController
|
||||
if params[:dmsf_link][:target_project_id].present?
|
||||
@dmsf_link.project_id = params[:dmsf_link][:target_project_id]
|
||||
else
|
||||
target_folder = DmsfFolder.find_by(id: params[:dmsf_link][:target_folder_id])
|
||||
unless target_folder
|
||||
project_id = DmsfFolder.find_by(id: params[:dmsf_link][:target_folder_id]).pluck(:project_id).first
|
||||
unless project_id
|
||||
render_404
|
||||
return
|
||||
end
|
||||
@dmsf_link.project_id = target_folder.project_id
|
||||
@dmsf_link.project_id = project_id
|
||||
end
|
||||
@dmsf_link.target_project_id = params[:dmsf_link][:project_id]
|
||||
if params[:dmsf_link][:dmsf_file_id].present?
|
||||
|
||||
@ -25,7 +25,7 @@ class DmsfPublicUrlsController < ApplicationController
|
||||
skip_before_action :check_if_login_required, :only => [:show]
|
||||
|
||||
def show
|
||||
dmsf_public_url = DmsfPublicUrl.where('token = ? AND expire_at >= ?', params[:token], DateTime.now).first
|
||||
dmsf_public_url = DmsfPublicUrl.where('token = ? AND expire_at >= ?', params[:token], DateTime.current).first
|
||||
if dmsf_public_url
|
||||
revision = dmsf_public_url.dmsf_file.last_revision
|
||||
begin
|
||||
|
||||
@ -27,7 +27,7 @@ class DmsfStateController < ApplicationController
|
||||
before_action :authorize
|
||||
|
||||
def user_pref_save
|
||||
member = @project.members.where(:user_id => User.current.id).first
|
||||
member = @project.members.where(user_id: User.current.id).first
|
||||
if member
|
||||
member.dmsf_mail_notification = params[:email_notify]
|
||||
member.dmsf_title_format = params[:title_format]
|
||||
|
||||
@ -114,7 +114,7 @@ class DmsfUploadController < ApplicationController
|
||||
@files = []
|
||||
attachments = params[:attachments]
|
||||
if attachments && attachments.is_a?(Hash)
|
||||
@folder = DmsfFolder.visible.find_by_id attachments[:folder_id].to_i if attachments[:folder_id].present?
|
||||
@folder = DmsfFolder.visible.find_by(id: attachments[:folder_id]) if attachments[:folder_id].present?
|
||||
# standard file input uploads
|
||||
uploaded_files = attachments.select { |key, value| key == 'uploaded_file'}
|
||||
uploaded_files.each_value do |uploaded_file|
|
||||
|
||||
@ -31,7 +31,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
layout :workflows_layout
|
||||
|
||||
def permissions
|
||||
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id] if params[:dmsf_file_revision_id].present?
|
||||
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id]) if params[:dmsf_file_revision_id].present?
|
||||
if revision
|
||||
render_403 unless revision.dmsf_file || DmsfFolder.permissions?(revision.dmsf_file.dmsf_folder)
|
||||
end
|
||||
@ -60,12 +60,12 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:note => params[:note])
|
||||
if request.post?
|
||||
if action.save
|
||||
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id]
|
||||
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
|
||||
if revision
|
||||
if @dmsf_workflow.try_finish revision, action, (params[:step_action].to_i / 10)
|
||||
if revision.dmsf_file
|
||||
begin
|
||||
revision.dmsf_file.unlock!(true) unless Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked'].present?
|
||||
revision.dmsf_file.unlock!(true) unless Setting.plugin_redmine_dmsf['dmsf_keep_documents_locked']
|
||||
rescue DmsfLockError => e
|
||||
flash[:info] = e.message
|
||||
end
|
||||
@ -82,7 +82,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_finished_approved,
|
||||
:text_email_to_see_history).deliver if user
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.blank?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
@ -92,7 +92,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
else
|
||||
# Just rejected
|
||||
recipients = @dmsf_workflow.participiants
|
||||
recipients.push User.find_by_id revision.dmsf_workflow_assigned_by
|
||||
recipients.push User.find_by(id: revision.dmsf_workflow_assigned_by)
|
||||
recipients.uniq!
|
||||
recipients = recipients & DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true)
|
||||
recipients.each do |user|
|
||||
@ -105,7 +105,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_to_see_history,
|
||||
action.note).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.blank?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
@ -116,7 +116,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
else
|
||||
if action.action == DmsfWorkflowStepAction::ACTION_DELEGATE
|
||||
# Delegation
|
||||
delegate = User.find_by_id params[:step_action].to_i / 10
|
||||
delegate = User.find_by(id: params[:step_action].to_i / 10)
|
||||
if DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(delegate)
|
||||
DmsfMailer.workflow_notification(
|
||||
delegate,
|
||||
@ -126,7 +126,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_finished_delegated,
|
||||
:text_email_to_proceed,
|
||||
action.note).deliver
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
flash[:warning] = l(:warning_email_notifications, :to => delegate.name)
|
||||
end
|
||||
end
|
||||
@ -147,7 +147,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_to_proceed).deliver
|
||||
end
|
||||
end
|
||||
to = User.find_by_id revision.dmsf_workflow_assigned_by
|
||||
to = User.find_by(id: revision.dmsf_workflow_assigned_by)
|
||||
if to && DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(to)
|
||||
DmsfMailer.workflow_notification(
|
||||
to,
|
||||
@ -157,7 +157,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
:text_email_finished_step_short,
|
||||
:text_email_to_see_status).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
recipients = assignments.collect{ |a| a.user }
|
||||
recipients << to if to
|
||||
recipients.uniq!
|
||||
@ -190,25 +190,29 @@ class DmsfWorkflowsController < ApplicationController
|
||||
params[:dmsf_workflow_id].present? && (params[:dmsf_workflow_id] != '-1')
|
||||
# DMS file
|
||||
if params[:dmsf_file_revision_id].present? && params[:dmsf_link_id].blank? && params[:attachment_id].blank?
|
||||
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id]
|
||||
if revision
|
||||
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
|
||||
revision.assign_workflow(params[:dmsf_workflow_id])
|
||||
if request.post?
|
||||
if revision.save
|
||||
file = DmsfFile.find_by_id revision.dmsf_file_id
|
||||
if file
|
||||
begin
|
||||
file.lock!
|
||||
rescue DmsfLockError => e
|
||||
Rails.logger.warn e.message
|
||||
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
|
||||
begin
|
||||
if revision
|
||||
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
|
||||
revision.assign_workflow(params[:dmsf_workflow_id])
|
||||
if request.post?
|
||||
if revision.save
|
||||
file = DmsfFile.find_by(id: revision.dmsf_file_id)
|
||||
if file
|
||||
begin
|
||||
file.lock!
|
||||
rescue DmsfLockError => e
|
||||
Rails.logger.warn e.message
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
else
|
||||
flash[:error] = l(:error_workflow_assign)
|
||||
end
|
||||
else
|
||||
flash[:error] = l(:error_workflow_assign)
|
||||
end
|
||||
end
|
||||
rescue StandardError => e
|
||||
flash[:error] = e.message
|
||||
end
|
||||
redirect_to :back
|
||||
return
|
||||
@ -249,8 +253,8 @@ class DmsfWorkflowsController < ApplicationController
|
||||
if params[:dmsf_workflow] && params[:dmsf_workflow][:name].present?
|
||||
@dmsf_workflow.name = params[:dmsf_workflow][:name]
|
||||
elsif params[:dmsf_workflow] && params[:dmsf_workflow][:id].present?
|
||||
wf = DmsfWorkflow.find_by_id params[:dmsf_workflow][:id]
|
||||
@dmsf_workflow.name = wf.name if wf
|
||||
names = DmsfWorkflow.find_by(id: params[:dmsf_workflow][:id]).pluck(:name)
|
||||
@dmsf_workflow.name = names.first
|
||||
end
|
||||
|
||||
render :layout => !request.xhr?
|
||||
@ -258,15 +262,15 @@ class DmsfWorkflowsController < ApplicationController
|
||||
|
||||
def create
|
||||
if params[:dmsf_workflow]
|
||||
if (params[:dmsf_workflow][:id].to_i > 0)
|
||||
wf = DmsfWorkflow.find_by_id params[:dmsf_workflow][:id]
|
||||
if params[:dmsf_workflow][:id].to_i > 0
|
||||
wf = DmsfWorkflow.find_by(id: params[:dmsf_workflow][:id])
|
||||
@dmsf_workflow = wf.copy_to(@project, params[:dmsf_workflow][:name]) if wf
|
||||
else
|
||||
@dmsf_workflow = DmsfWorkflow.new
|
||||
@dmsf_workflow.name = params[:dmsf_workflow][:name]
|
||||
@dmsf_workflow.project_id = @project.id if @project
|
||||
@dmsf_workflow.author = User.current
|
||||
@dmsf_workflow.save
|
||||
@dmsf_workflow.save!
|
||||
end
|
||||
end
|
||||
if request.post? && @dmsf_workflow && @dmsf_workflow.valid?
|
||||
@ -338,13 +342,13 @@ class DmsfWorkflowsController < ApplicationController
|
||||
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]).to_a
|
||||
if users.count > 0
|
||||
users.each do |user|
|
||||
user_ids = User.where(id: params[:user_ids]).ids
|
||||
if user_ids.count > 0
|
||||
user_ids.each do |user_id|
|
||||
ws = DmsfWorkflowStep.new
|
||||
ws.dmsf_workflow_id = @dmsf_workflow.id
|
||||
ws.step = step
|
||||
ws.user_id = user.id
|
||||
ws.user_id = user_id
|
||||
ws.operator = operator
|
||||
ws.name = params[:name]
|
||||
if ws.save
|
||||
@ -364,7 +368,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
|
||||
def remove_step
|
||||
if request.delete?
|
||||
DmsfWorkflowStep.where(:dmsf_workflow_id => @dmsf_workflow.id, :step => params[:step]).each do |ws|
|
||||
DmsfWorkflowStep.where(dmsf_workflow_id: @dmsf_workflow.id, step: params[:step]).find_each do |ws|
|
||||
@dmsf_workflow.dmsf_workflow_steps.delete(ws)
|
||||
end
|
||||
@dmsf_workflow.dmsf_workflow_steps.each do |ws|
|
||||
@ -395,7 +399,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
end
|
||||
|
||||
def start
|
||||
revision = DmsfFileRevision.find_by_id(params[:dmsf_file_revision_id])
|
||||
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
|
||||
if revision
|
||||
revision.set_workflow(@dmsf_workflow.id, params[:action])
|
||||
if revision.save
|
||||
@ -415,21 +419,21 @@ class DmsfWorkflowsController < ApplicationController
|
||||
name = params[:dmsf_workflow][:name]
|
||||
step = @dmsf_workflow.dmsf_workflow_steps[index]
|
||||
step.name = name
|
||||
unless step.save
|
||||
flash[:error] = step.errors.full_messages.to_sentence
|
||||
else
|
||||
if step.save
|
||||
@dmsf_workflow.dmsf_workflow_steps.each do |s|
|
||||
if s.step == step.step
|
||||
s.name = step.name
|
||||
s.save
|
||||
s.save!
|
||||
end
|
||||
end
|
||||
else
|
||||
flash[:error] = step.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
# Operators/Assignees
|
||||
if params[:operator_step].present?
|
||||
params[:operator_step].each do |id, operator|
|
||||
step = DmsfWorkflowStep.find_by_id id
|
||||
step = DmsfWorkflowStep.find_by(id: id)
|
||||
if step
|
||||
step.operator = operator.to_i
|
||||
step.user_id = params[:assignee][id]
|
||||
@ -444,14 +448,14 @@ class DmsfWorkflowsController < ApplicationController
|
||||
end
|
||||
|
||||
def delete_step
|
||||
step = DmsfWorkflowStep.find_by_id params[:step]
|
||||
step = DmsfWorkflowStep.find_by(id: params[:step])
|
||||
if step
|
||||
# Safe the name
|
||||
if step.name.present?
|
||||
@dmsf_workflow.dmsf_workflow_steps.each do |s|
|
||||
if s.step == step.step
|
||||
s.name = step.name
|
||||
s.save
|
||||
s.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -468,14 +472,14 @@ private
|
||||
if @dmsf_workflow.project # Project workflow
|
||||
@project = @dmsf_workflow.project
|
||||
else # Global workflow
|
||||
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id]
|
||||
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
|
||||
@project = revision.dmsf_file.project if revision && revision.dmsf_file
|
||||
end
|
||||
else
|
||||
if params[:dmsf_workflow]
|
||||
@project = Project.find_by_id params[:dmsf_workflow][:project_id]
|
||||
@project = Project.find params[:dmsf_workflow][:project_id]
|
||||
elsif params[:project_id]
|
||||
@project = Project.find_by_id params[:project_id]
|
||||
@project = Project.find params[:project_id]
|
||||
else
|
||||
@project = Project.find params[:id]
|
||||
end
|
||||
|
||||
@ -37,8 +37,8 @@ module DmsfHelper
|
||||
|
||||
def self.temp_filename(filename)
|
||||
filename = sanitize_filename(filename)
|
||||
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
||||
while self.temp_dir.join("#{timestamp}_#{filename}").exist?
|
||||
timestamp = DateTime.current.strftime('%y%m%d%H%M%S')
|
||||
while temp_dir.join("#{timestamp}_#{filename}").exist?
|
||||
timestamp.succ!
|
||||
end
|
||||
"#{timestamp}_#{filename}"
|
||||
@ -101,16 +101,16 @@ module DmsfHelper
|
||||
User.current.allowed_to?(:display_system_folders, project)
|
||||
folders.reject{ |folder|
|
||||
if folder.system
|
||||
unless allowed
|
||||
true
|
||||
else
|
||||
if allowed
|
||||
issue_id = folder.title.to_i
|
||||
if issue_id > 0
|
||||
issue = Issue.find_by_id issue_id
|
||||
issue = Issue.find_by(id: issue_id)
|
||||
issue && !issue.visible?(User.current)
|
||||
else
|
||||
false
|
||||
end
|
||||
else
|
||||
true
|
||||
end
|
||||
else
|
||||
false
|
||||
@ -123,11 +123,11 @@ module DmsfHelper
|
||||
nodes = visible_folders(parent.dmsf_folders.visible.to_a, parent.is_a?(Project) ? parent : parent.project) + parent.dmsf_links.visible + parent.dmsf_files.visible
|
||||
# Alphabetical and type sort
|
||||
nodes.sort! do |x, y|
|
||||
if ((x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) &&
|
||||
(y.is_a?(DmsfFile) || (y.is_a?(DmsfLink) && y.is_file?)))
|
||||
if (x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) &&
|
||||
(y.is_a?(DmsfFile) || (y.is_a?(DmsfLink) && y.is_file?))
|
||||
-1
|
||||
elsif ((x.is_a?(DmsfFile) || (x.is_a?(DmsfLink) && x.is_file?)) &&
|
||||
(y.is_a?(DmsfFolder) || (y.is_a?(DmsfLink) && y.is_folder?)))
|
||||
elsif (x.is_a?(DmsfFile) || (x.is_a?(DmsfLink) && x.is_file?)) &&
|
||||
(y.is_a?(DmsfFolder) || (y.is_a?(DmsfLink) && y.is_folder?))
|
||||
1
|
||||
else
|
||||
x.title.downcase <=> y.title.downcase
|
||||
|
||||
@ -42,10 +42,10 @@ module DmsfLinksHelper
|
||||
def files_for_select(project_id, folder_id)
|
||||
files = []
|
||||
if folder_id && (folder_id != '0')
|
||||
folder = DmsfFolder.find_by_id folder_id
|
||||
folder = DmsfFolder.find_by(id: folder_id)
|
||||
files = folder.dmsf_files.visible.to_a if folder
|
||||
elsif project_id
|
||||
project = Project.find_by_id project_id
|
||||
project = Project.find_by(id: project_id)
|
||||
files = project.dmsf_files.visible.to_a if project
|
||||
end
|
||||
files
|
||||
|
||||
@ -35,15 +35,7 @@ module DmsfUploadHelper
|
||||
file = link.target_file if link
|
||||
end
|
||||
|
||||
unless file
|
||||
file = DmsfFile.new
|
||||
file.project_id = project.id
|
||||
file.name = name
|
||||
file.dmsf_folder = folder
|
||||
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
||||
new_revision.minor_version = 0
|
||||
new_revision.major_version = 0
|
||||
else
|
||||
if file
|
||||
if file.last_revision
|
||||
last_revision = file.last_revision
|
||||
new_revision.source_revision = last_revision
|
||||
@ -53,6 +45,14 @@ module DmsfUploadHelper
|
||||
new_revision.minor_version = 0
|
||||
new_revision.major_version = 0
|
||||
end
|
||||
else
|
||||
file = DmsfFile.new
|
||||
file.project_id = project.id
|
||||
file.name = name
|
||||
file.dmsf_folder = folder
|
||||
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
||||
new_revision.minor_version = 0
|
||||
new_revision.major_version = 0
|
||||
end
|
||||
|
||||
if file.locked_for_user?
|
||||
@ -117,7 +117,7 @@ module DmsfUploadHelper
|
||||
end
|
||||
# Approval workflow
|
||||
if commited_file[:workflow_id].present?
|
||||
wf = DmsfWorkflow.find_by_id commited_file[:workflow_id]
|
||||
wf = DmsfWorkflow.find_by(id: commited_file[:workflow_id])
|
||||
if wf
|
||||
# Assign the workflow
|
||||
new_revision.set_workflow(wf.id, 'assign')
|
||||
@ -138,13 +138,13 @@ module DmsfUploadHelper
|
||||
end
|
||||
end
|
||||
# Notifications
|
||||
if ((folder && folder.notification?) || (!folder && project.dmsf_notification?))
|
||||
if (folder && folder.notification?) || (!folder && project.dmsf_notification?)
|
||||
begin
|
||||
recipients = DmsfMailer.get_notify_users(project, files)
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_updated(u, project, files).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
|
||||
@ -38,9 +38,11 @@ module DmsfWorkflowsHelper
|
||||
:class => 'objects-selection')
|
||||
end
|
||||
|
||||
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, autocomplete_for_user_dmsf_workflow_path(workflow, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
|
||||
}
|
||||
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) do |text, parameters, options|
|
||||
link_to text,
|
||||
autocomplete_for_user_dmsf_workflow_path(workflow, parameters.merge(:q => params[:q], :format => 'js')),
|
||||
remote: true
|
||||
end
|
||||
|
||||
s + content_tag('span', links, :class => 'pagination')
|
||||
end
|
||||
@ -72,7 +74,7 @@ module DmsfWorkflowsHelper
|
||||
options << ['', 0]
|
||||
DmsfWorkflow.active.sorted.all.each do |wf|
|
||||
if wf.project_id
|
||||
prj = Project.find_by_id wf.project_id
|
||||
prj = Project.find_by(id: wf.project_id)
|
||||
if User.current.allowed_to?(:manage_workflows, prj)
|
||||
# Local approval workflows
|
||||
if prj
|
||||
|
||||
@ -37,7 +37,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
belongs_to :dmsf_folder
|
||||
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
||||
|
||||
has_many :dmsf_file_revisions, -> { order("#{DmsfFileRevision.table_name}.id DESC") },
|
||||
has_many :dmsf_file_revisions, -> { order("#{DmsfFileRevision.table_name}.created_at DESC") },
|
||||
: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
|
||||
@ -48,18 +48,13 @@ class DmsfFile < ActiveRecord::Base
|
||||
STATUS_DELETED = 1
|
||||
STATUS_ACTIVE = 0
|
||||
|
||||
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
|
||||
scope :visible, -> { where(deleted: STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(deleted: STATUS_DELETED) }
|
||||
|
||||
validates_presence_of :name, :project
|
||||
validates_format_of :name, :with => /\A[^#{DmsfFolder::INVALID_CHARACTERS}]*\z/,
|
||||
:message => l(:error_contains_invalid_character)
|
||||
validate :validates_name_uniqueness
|
||||
|
||||
def validates_name_uniqueness
|
||||
existing_file = DmsfFile.select(:id).findn_file_by_name(self.project_id, self.dmsf_folder, self.name)
|
||||
errors.add(:name, l('activerecord.errors.messages.taken')) unless (existing_file.nil? || existing_file.id == self.id)
|
||||
end
|
||||
validates :name, presence: true, dmsf_file_name: true
|
||||
validates :project, presence: true
|
||||
validates_uniqueness_of :name, :scope => [:dmsf_folder_id, :project_id, :deleted],
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }
|
||||
|
||||
acts_as_event :title => Proc.new { |o| o.name },
|
||||
:description => Proc.new { |o|
|
||||
@ -85,7 +80,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
before_create :default_values
|
||||
|
||||
def default_values
|
||||
if (Setting.plugin_redmine_dmsf['dmsf_default_notifications'] == '1') && (!self.dmsf_folder || !self.dmsf_folder.system)
|
||||
if (Setting.plugin_redmine_dmsf['dmsf_default_notifications'] == '1') && (!dmsf_folder || !dmsf_folder.system)
|
||||
self.notification = true
|
||||
end
|
||||
end
|
||||
@ -107,19 +102,19 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.find_file_by_name(project, folder, name)
|
||||
self.findn_file_by_name(project.id, folder, name)
|
||||
findn_file_by_name(project.id, folder, name)
|
||||
end
|
||||
|
||||
def self.findn_file_by_name(project_id, folder, name)
|
||||
where(
|
||||
:project_id => project_id,
|
||||
:dmsf_folder_id => folder ? folder.id : nil,
|
||||
:name => name).visible.first
|
||||
project_id: project_id,
|
||||
dmsf_folder_id: folder ? folder.id : nil,
|
||||
name: name).visible.first
|
||||
end
|
||||
|
||||
def last_revision
|
||||
unless defined?(@last_revision)
|
||||
@last_revision = self.deleted? ? self.dmsf_file_revisions.first : self.dmsf_file_revisions.visible.first
|
||||
@last_revision = deleted? ? dmsf_file_revisions.first : dmsf_file_revisions.visible.first
|
||||
end
|
||||
@last_revision
|
||||
end
|
||||
@ -129,14 +124,14 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def deleted?
|
||||
self.deleted == STATUS_DELETED
|
||||
deleted == STATUS_DELETED
|
||||
end
|
||||
|
||||
def delete(commit)
|
||||
if locked_for_user? && (!User.current.allowed_to?(:force_file_unlock, self.project))
|
||||
if locked_for_user? && (!User.current.allowed_to?(:force_file_unlock, project))
|
||||
Rails.logger.info l(:error_file_is_locked)
|
||||
if self.lock.reverse[0].user
|
||||
errors[:base] << l(:title_locked_by_user, :user => self.lock.reverse[0].user)
|
||||
if lock.reverse[0].user
|
||||
errors[:base] << l(:title_locked_by_user, :user => lock.reverse[0].user)
|
||||
else
|
||||
errors[:base] << l(:error_file_is_locked)
|
||||
end
|
||||
@ -144,12 +139,12 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
begin
|
||||
# Revisions and links of a deleted file SHOULD be deleted too
|
||||
self.dmsf_file_revisions.each { |r| r.delete(commit, true) }
|
||||
dmsf_file_revisions.each { |r| r.delete(commit, true) }
|
||||
if commit
|
||||
if self.container.is_a?(Issue)
|
||||
self.container.dmsf_file_removed(self)
|
||||
if container.is_a?(Issue)
|
||||
container.dmsf_file_removed(self)
|
||||
end
|
||||
self.destroy
|
||||
destroy
|
||||
else
|
||||
self.deleted = STATUS_DELETED
|
||||
self.deleted_by_user = User.current
|
||||
@ -163,61 +158,61 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def restore
|
||||
if self.dmsf_folder_id && (self.dmsf_folder.nil? || self.dmsf_folder.deleted?)
|
||||
if dmsf_folder_id && (dmsf_folder.nil? || dmsf_folder.deleted?)
|
||||
errors[:base] << l(:error_parent_folder)
|
||||
return false
|
||||
end
|
||||
self.dmsf_file_revisions.each { |r| r.restore }
|
||||
dmsf_file_revisions.each { |r| r.restore }
|
||||
self.deleted = STATUS_ACTIVE
|
||||
self.deleted_by_user = nil
|
||||
save
|
||||
end
|
||||
|
||||
def title
|
||||
self.last_revision ? self.last_revision.title : self.name
|
||||
last_revision ? last_revision.title : name
|
||||
end
|
||||
|
||||
def description
|
||||
self.last_revision ? self.last_revision.description : ''
|
||||
last_revision ? last_revision.description : ''
|
||||
end
|
||||
|
||||
def version
|
||||
self.last_revision ? self.last_revision.version : '0'
|
||||
last_revision ? last_revision.version : '0'
|
||||
end
|
||||
|
||||
def workflow
|
||||
self.last_revision ? self.last_revision.workflow : nil
|
||||
last_revision ? last_revision.workflow : nil
|
||||
end
|
||||
|
||||
def size
|
||||
self.last_revision ? self.last_revision.size : 0
|
||||
last_revision ? last_revision.size : 0
|
||||
end
|
||||
|
||||
def dmsf_path
|
||||
path = self.dmsf_folder ? self.dmsf_folder.dmsf_path : []
|
||||
path = dmsf_folder ? dmsf_folder.dmsf_path : []
|
||||
path.push(self)
|
||||
path
|
||||
end
|
||||
|
||||
def dmsf_path_str
|
||||
self.dmsf_path.map { |element| element.title }.join('/')
|
||||
dmsf_path.map { |element| element.title }.join('/')
|
||||
end
|
||||
|
||||
def notify?
|
||||
return true if self.notification
|
||||
return true if self.dmsf_folder && self.dmsf_folder.notify?
|
||||
return true if !self.dmsf_folder && self.project.dmsf_notification
|
||||
return false
|
||||
return true if notification
|
||||
return true if dmsf_folder && dmsf_folder.notify?
|
||||
return true if !dmsf_folder && project.dmsf_notification
|
||||
false
|
||||
end
|
||||
|
||||
def notify_deactivate
|
||||
self.notification = nil
|
||||
self.save!
|
||||
save!
|
||||
end
|
||||
|
||||
def notify_activate
|
||||
self.notification = true
|
||||
self.save!
|
||||
save!
|
||||
end
|
||||
|
||||
# Returns an array of projects that current user can copy file to
|
||||
@ -235,26 +230,26 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def move_to(project, folder)
|
||||
if self.locked_for_user?
|
||||
if locked_for_user?
|
||||
errors[:base] << l(:error_file_is_locked)
|
||||
return false
|
||||
end
|
||||
source = "#{self.project.identifier}:#{self.dmsf_path_str}"
|
||||
source = "#{project.identifier}:#{dmsf_path_str}"
|
||||
self.project_id = project.id
|
||||
self.dmsf_folder = folder
|
||||
new_revision = self.last_revision.clone
|
||||
new_revision = last_revision.clone
|
||||
new_revision.dmsf_file = self
|
||||
new_revision.comment = l(:comment_moved_from, :source => source)
|
||||
new_revision.custom_values = []
|
||||
self.last_revision.custom_values.each do |cv|
|
||||
last_revision.custom_values.each do |cv|
|
||||
new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
||||
end
|
||||
self.set_last_revision(new_revision)
|
||||
self.save && new_revision.save
|
||||
set_last_revision(new_revision)
|
||||
save && new_revision.save
|
||||
end
|
||||
|
||||
def copy_to(project, folder = nil)
|
||||
copy_to_filename(project, folder, self.name)
|
||||
copy_to_filename(project, folder, name)
|
||||
end
|
||||
|
||||
def copy_to_filename(project, folder, filename)
|
||||
@ -263,8 +258,8 @@ class DmsfFile < ActiveRecord::Base
|
||||
file.project_id = project.id
|
||||
file.name = filename
|
||||
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
||||
if file.save && self.last_revision
|
||||
new_revision = self.last_revision.clone
|
||||
if file.save && last_revision
|
||||
new_revision = last_revision.clone
|
||||
new_revision.dmsf_file = file
|
||||
new_revision.disk_filename = new_revision.new_storage_filename
|
||||
# Assign the same workflow if it's a global one or we are in the same project
|
||||
@ -279,23 +274,23 @@ class DmsfFile < ActiveRecord::Base
|
||||
new_revision.set_workflow(wf.id, nil)
|
||||
new_revision.assign_workflow(wf.id)
|
||||
end
|
||||
if File.exist? self.last_revision.disk_file
|
||||
FileUtils.cp self.last_revision.disk_file, new_revision.disk_file(false)
|
||||
if File.exist? last_revision.disk_file
|
||||
FileUtils.cp last_revision.disk_file, new_revision.disk_file(false)
|
||||
end
|
||||
new_revision.comment = l(:comment_copied_from, :source => "#{project.identifier}: #{self.dmsf_path_str}")
|
||||
new_revision.comment = l(:comment_copied_from, :source => "#{project.identifier}: #{dmsf_path_str}")
|
||||
new_revision.custom_values = []
|
||||
self.last_revision.custom_values.each do |cv|
|
||||
last_revision.custom_values.each do |cv|
|
||||
v = CustomValue.new
|
||||
v.custom_field = cv.custom_field
|
||||
v.value = cv.value
|
||||
new_revision.custom_values << v
|
||||
end
|
||||
unless new_revision.save
|
||||
if new_revision.save
|
||||
file.set_last_revision new_revision
|
||||
else
|
||||
Rails.logger.error new_revision.errors.full_messages.to_sentence
|
||||
file.delete(true)
|
||||
file = nil
|
||||
else
|
||||
file.set_last_revision new_revision
|
||||
end
|
||||
else
|
||||
Rails.logger.error file.errors.full_messages.to_sentence
|
||||
@ -330,7 +325,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
project_conditions << Project.allowed_to_condition(user, :view_dmsf_files)
|
||||
project_conditions << "#{Project.table_name}.id IN (#{project_ids.join(',')})" if project_ids.present?
|
||||
|
||||
scope = self.visible.joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').joins(:project)
|
||||
scope = visible.joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').joins(:project)
|
||||
scope = scope.limit(options[:limit]) unless options[:limit].blank?
|
||||
scope = scope.where(limit_options) unless limit_options.blank?
|
||||
scope = scope.where(project_conditions.join(' AND '))
|
||||
@ -377,7 +372,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
flags = Xapian::QueryParser::FLAG_WILDCARD
|
||||
flags |= Xapian::QueryParser::FLAG_CJK_NGRAM if Setting.plugin_redmine_dmsf['enable_cjk_ngrams']
|
||||
flags |= Xapian::QueryParser::FLAG_CJK_NGRAM if Setting.plugin_redmine_dmsf['dmsf_enable_cjk_ngrams']
|
||||
|
||||
query = qp.parse_query(query_string, flags)
|
||||
|
||||
@ -396,7 +391,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
next if dmsf_attrs.length == 0 || id_attribute == 0
|
||||
next unless results.select{|f| f.id.to_s == id_attribute}.empty?
|
||||
|
||||
dmsf_file = DmsfFile.visible.where(limit_options).where(:id => id_attribute).first
|
||||
dmsf_file = DmsfFile.visible.where(limit_options).where(id: id_attribute).first
|
||||
|
||||
if dmsf_file && DmsfFolder.permissions?(dmsf_file.dmsf_folder)
|
||||
if user.allowed_to?(:view_dmsf_files, dmsf_file.project) &&
|
||||
@ -417,12 +412,12 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search_result_ranks_and_ids(tokens, user = User.current, projects = nil, options = {})
|
||||
r = self.search(tokens, projects, options, user)[0]
|
||||
r = search(tokens, projects, options, user)[0]
|
||||
r.map{ |f| [f.updated_at.to_i, f.id]}
|
||||
end
|
||||
|
||||
def display_name
|
||||
member = Member.where(:user_id => User.current.id, :project_id => self.project_id).first
|
||||
member = Member.where(user_id: User.current.id, project_id: project_id).first
|
||||
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
|
||||
title_format = member.dmsf_title_format
|
||||
else
|
||||
@ -436,27 +431,27 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def text?
|
||||
self.last_revision && Redmine::MimeType.is_type?('text', self.last_revision.disk_filename)
|
||||
last_revision && Redmine::MimeType.is_type?('text', last_revision.disk_filename)
|
||||
end
|
||||
|
||||
def image?
|
||||
self.last_revision && Redmine::MimeType.is_type?('image', self.last_revision.disk_filename)
|
||||
last_revision && Redmine::MimeType.is_type?('image', last_revision.disk_filename)
|
||||
end
|
||||
|
||||
def pdf?
|
||||
self.last_revision && (Redmine::MimeType.of(self.last_revision.disk_filename) == 'application/pdf')
|
||||
last_revision && (Redmine::MimeType.of(last_revision.disk_filename) == 'application/pdf')
|
||||
end
|
||||
|
||||
|
||||
def disposition
|
||||
(self.image? || self.pdf?) ? 'inline' : 'attachment'
|
||||
(image? || pdf?) ? 'inline' : 'attachment'
|
||||
end
|
||||
|
||||
def preview(limit)
|
||||
result = 'No preview available'
|
||||
if self.text?
|
||||
if text?
|
||||
begin
|
||||
f = File.new(self.last_revision.disk_file)
|
||||
f = File.new(last_revision.disk_file)
|
||||
f.each_line do |line|
|
||||
case f.lineno
|
||||
when 1
|
||||
@ -475,10 +470,10 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def formatted_name(format)
|
||||
if self.last_revision
|
||||
self.last_revision.formatted_name(format)
|
||||
if last_revision
|
||||
last_revision.formatted_name(format)
|
||||
else
|
||||
self.name
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
@ -503,7 +498,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def custom_value(custom_field)
|
||||
self.last_revision.custom_field_values.each do |cv|
|
||||
last_revision.custom_field_values.each do |cv|
|
||||
if cv.custom_field == custom_field
|
||||
if cv.value.is_a? Array
|
||||
return cv.value.reject{ |x| x.empty? }.join(',')
|
||||
@ -525,51 +520,51 @@ class DmsfFile < ActiveRecord::Base
|
||||
def to_csv(columns, level)
|
||||
csv = []
|
||||
# Project
|
||||
csv << self.project.name if columns.include?(l(:field_project))
|
||||
csv << project.name if columns.include?(l(:field_project))
|
||||
# Id
|
||||
csv << self.id if columns.include?('id')
|
||||
csv << id if columns.include?('id')
|
||||
# Title
|
||||
csv << self.title.insert(0, ' ' * level) if columns.include?('title')
|
||||
csv << title.insert(0, ' ' * level) if columns.include?('title')
|
||||
# Extension
|
||||
csv << self.extension if columns.include?('extension')
|
||||
csv << extension if columns.include?('extension')
|
||||
# Size
|
||||
csv << number_to_human_size(self.last_revision.size) if columns.include?('size')
|
||||
csv << number_to_human_size(last_revision.size) if columns.include?('size')
|
||||
# Modified
|
||||
if columns.include?('modified')
|
||||
if self.last_revision
|
||||
csv << format_time(self.last_revision.updated_at)
|
||||
if last_revision
|
||||
csv << format_time(last_revision.updated_at)
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
end
|
||||
# Version
|
||||
if columns.include?('version')
|
||||
if self.last_revision
|
||||
csv << self.last_revision.version
|
||||
if last_revision
|
||||
csv << last_revision.version
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
end
|
||||
# Workflow
|
||||
if columns.include?('workflow')
|
||||
if self.last_revision
|
||||
csv << self.last_revision.workflow_str(false)
|
||||
if last_revision
|
||||
csv << last_revision.workflow_str(false)
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
end
|
||||
# Author
|
||||
if columns.include?('author')
|
||||
if self.last_revision && self.last_revision.user
|
||||
csv << self.last_revision.user.name
|
||||
if last_revision && last_revision.user
|
||||
csv << last_revision.user.name
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
end
|
||||
# Last approver
|
||||
if columns.include?(l(:label_last_approver))
|
||||
if self.last_revision && self.last_revision.dmsf_workflow
|
||||
csv << self.last_revision.workflow_tooltip
|
||||
if last_revision && last_revision.dmsf_workflow
|
||||
csv << last_revision.workflow_tooltip
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
@ -577,20 +572,19 @@ class DmsfFile < ActiveRecord::Base
|
||||
# Url
|
||||
if columns.include?(l(:label_document_url))
|
||||
default_url_options[:host] = Setting.host_name
|
||||
csv << url_for(:controller => :dmsf_files, :action => 'view', :id => self.id)
|
||||
csv << url_for(:controller => :dmsf_files, :action => 'view', :id => id)
|
||||
end
|
||||
# Revision
|
||||
if columns.include?(l(:label_last_revision_id))
|
||||
if self.last_revision
|
||||
csv << self.last_revision.id
|
||||
if last_revision
|
||||
csv << last_revision.id
|
||||
else
|
||||
csv << ''
|
||||
end
|
||||
end
|
||||
# Custom fields
|
||||
cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position)
|
||||
cfs.each do |c|
|
||||
csv << self.custom_value(c) if columns.include?(c.name)
|
||||
CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c|
|
||||
csv << custom_value(c) if columns.include?(c.name)
|
||||
end
|
||||
csv
|
||||
end
|
||||
@ -607,21 +601,21 @@ class DmsfFile < ActiveRecord::Base
|
||||
size = Setting.thumbnails_size.to_i
|
||||
end
|
||||
size = 100 unless size > 0
|
||||
target = File.join(Attachment.thumbnails_storage_path, "#{self.id}_#{self.last_revision.digest}_#{size}.thumb")
|
||||
target = File.join(Attachment.thumbnails_storage_path, "#{id}_#{last_revision.digest}_#{size}.thumb")
|
||||
|
||||
begin
|
||||
Redmine::Thumbnail.generate(self.last_revision.disk_file.to_s, target, size)
|
||||
Redmine::Thumbnail.generate(last_revision.disk_file.to_s, target, size)
|
||||
rescue => e
|
||||
Rails.logger.error "An error occured while generating thumbnail for #{self.last_revision.disk_file} to #{target}\nException was: #{e.message}"
|
||||
return nil
|
||||
Rails.logger.error "An error occured while generating thumbnail for #{last_revision.disk_file} to #{target}\nException was: #{e.message}"
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_locked_title
|
||||
if self.locked_for_user?
|
||||
if self.lock.reverse[0].user
|
||||
return l(:title_locked_by_user, :user => self.lock.reverse[0].user)
|
||||
if locked_for_user?
|
||||
if lock.reverse[0].user
|
||||
return l(:title_locked_by_user, :user => lock.reverse[0].user)
|
||||
else
|
||||
return l(:notice_account_unknown_email)
|
||||
end
|
||||
@ -631,8 +625,8 @@ class DmsfFile < ActiveRecord::Base
|
||||
|
||||
def container
|
||||
unless @container
|
||||
if self.dmsf_folder && self.dmsf_folder.system
|
||||
@container = Issue.where(:id => self.dmsf_folder.title.to_i).first
|
||||
if dmsf_folder && dmsf_folder.system
|
||||
@container = Issue.find_by(id: dmsf_folder.title.to_i)
|
||||
end
|
||||
end
|
||||
@container
|
||||
|
||||
@ -48,8 +48,8 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
'application/vnd.oasis.opendocument.presentation' => 'ms-powerpoint',
|
||||
}.freeze
|
||||
|
||||
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
|
||||
scope :visible, -> { where(deleted: STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(deleted: STATUS_DELETED) }
|
||||
|
||||
acts_as_customizable
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_dmsf_updated)}: #{o.dmsf_file.dmsf_path_str}"},
|
||||
@ -65,17 +65,19 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
:scope => DmsfFileRevision.joins(:dmsf_file).
|
||||
joins("JOIN #{Project.table_name} ON #{Project.table_name}.id = #{DmsfFile.table_name}.project_id").visible
|
||||
|
||||
validates_presence_of :title, :major_version, :minor_version, :dmsf_file
|
||||
validates_format_of :name, :with => /\A[^#{DmsfFolder::INVALID_CHARACTERS}]*\z/,
|
||||
:message => l(:error_contains_invalid_character)
|
||||
validates :title, presence: true
|
||||
validates :major_version, presence: true
|
||||
validates :minor_version, presence: true
|
||||
validates :dmsf_file, presence: true
|
||||
validates :name, dmsf_file_name: true
|
||||
validates :description, length: { maximum: 1.kilobyte }
|
||||
|
||||
def project
|
||||
self.dmsf_file.project if self.dmsf_file
|
||||
dmsf_file.project if dmsf_file
|
||||
end
|
||||
|
||||
def folder
|
||||
self.dmsf_file.dmsf_folder if self.dmsf_file
|
||||
dmsf_file.dmsf_folder if dmsf_file
|
||||
end
|
||||
|
||||
def self.remove_extension(filename)
|
||||
@ -87,21 +89,21 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.easy_activity_custom_project_scope(scope, options, event_type)
|
||||
scope.where(:dmsf_files => { :project_id => options[:project_ids] })
|
||||
scope.where(:dmsf_files => { project_id: options[:project_ids] })
|
||||
end
|
||||
|
||||
def delete(commit = false, force = true)
|
||||
if self.dmsf_file.locked_for_user?
|
||||
if dmsf_file.locked_for_user?
|
||||
errors[:base] << l(:error_file_is_locked)
|
||||
return false
|
||||
end
|
||||
if !commit && (!force && (self.dmsf_file.dmsf_file_revisions.length <= 1))
|
||||
if !commit && (!force && (dmsf_file.dmsf_file_revisions.length <= 1))
|
||||
errors[:base] << l(:error_at_least_one_revision_must_be_present)
|
||||
return false
|
||||
end
|
||||
|
||||
if commit
|
||||
self.destroy
|
||||
destroy
|
||||
else
|
||||
self.deleted = DmsfFile::STATUS_DELETED
|
||||
self.deleted_by_user = User.current
|
||||
@ -109,8 +111,8 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def obsolete()
|
||||
if self.dmsf_file.locked_for_user?
|
||||
def obsolete
|
||||
if dmsf_file.locked_for_user?
|
||||
errors[:base] << l(:error_file_is_locked)
|
||||
return false
|
||||
end
|
||||
@ -125,14 +127,13 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def destroy
|
||||
dependent = DmsfFileRevision.where(:source_dmsf_file_revision_id => self.id).all
|
||||
dependent.each do |d|
|
||||
d.source_revision = self.source_revision
|
||||
DmsfFileRevision.where(source_dmsf_file_revision_id: id).find_each do |d|
|
||||
d.source_revision = source_revision
|
||||
d.save!
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_really_delete_files']
|
||||
dependencies = DmsfFileRevision.where(:disk_filename => self.disk_filename).count
|
||||
File.delete(self.disk_file) if dependencies <= 1 && File.exist?(self.disk_file)
|
||||
dependencies = DmsfFileRevision.where(disk_filename: disk_filename).all.size
|
||||
File.delete(disk_file) if dependencies <= 1 && File.exist?(disk_file)
|
||||
end
|
||||
super
|
||||
end
|
||||
@ -149,35 +150,34 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
# custom SQL into a temporary object
|
||||
#
|
||||
def access_grouped
|
||||
self.dmsf_file_revision_access.select('user_id, COUNT(*) AS count, MIN(created_at) AS first_at, MAX(created_at) AS last_at').group('user_id')
|
||||
dmsf_file_revision_access.select('user_id, COUNT(*) AS count, MIN(created_at) AS first_at, MAX(created_at) AS last_at').group('user_id')
|
||||
end
|
||||
|
||||
def version
|
||||
ver = DmsfUploadHelper::gui_version(self.major_version).to_s
|
||||
if -self.minor_version != ' '.ord
|
||||
ver << ".#{DmsfUploadHelper::gui_version(self.minor_version)}"
|
||||
ver = DmsfUploadHelper::gui_version(major_version).to_s
|
||||
if -minor_version != ' '.ord
|
||||
ver << ".#{DmsfUploadHelper::gui_version(minor_version)}"
|
||||
end
|
||||
ver
|
||||
end
|
||||
|
||||
def storage_base_path
|
||||
time = self.created_at || DateTime.now
|
||||
time = created_at || DateTime.current
|
||||
DmsfFile.storage_path.join(time.strftime('%Y')).join(time.strftime('%m'))
|
||||
end
|
||||
|
||||
def disk_file(search_if_not_exists = true)
|
||||
path = self.storage_base_path
|
||||
path = storage_base_path
|
||||
begin
|
||||
FileUtils.mkdir_p(path) unless File.exist?(path)
|
||||
rescue StandardError => e
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
filename = path.join(self.disk_filename)
|
||||
filename = path.join(disk_filename)
|
||||
if search_if_not_exists
|
||||
unless File.exist?(filename)
|
||||
# Let's search for the physical file in source revisions
|
||||
revisions = self.dmsf_file.dmsf_file_revisions.where(['id < ?', self.id]).order(:id => :desc)
|
||||
revisions.each do |rev|
|
||||
dmsf_file.dmsf_file_revisions.where(['id < ?', id]).order(created_at: :desc).each do |rev|
|
||||
filename = rev.disk_file
|
||||
break if File.exist?(filename)
|
||||
end
|
||||
@ -187,45 +187,45 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def new_storage_filename
|
||||
raise DmsfAccessError, 'File id is not set' unless self.dmsf_file.id
|
||||
filename = DmsfHelper.sanitize_filename(self.name)
|
||||
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
||||
while File.exist?(storage_base_path.join("#{timestamp}_#{self.dmsf_file.id}_#{filename}"))
|
||||
raise DmsfAccessError, 'File id is not set' unless dmsf_file.id
|
||||
filename = DmsfHelper.sanitize_filename(name)
|
||||
timestamp = DateTime.current.strftime('%y%m%d%H%M%S')
|
||||
while File.exist?(storage_base_path.join("#{timestamp}_#{dmsf_file.id}_#{filename}"))
|
||||
timestamp.succ!
|
||||
end
|
||||
"#{timestamp}_#{self.dmsf_file.id}_#{filename}"
|
||||
"#{timestamp}_#{dmsf_file.id}_#{filename}"
|
||||
end
|
||||
|
||||
def detect_content_type
|
||||
content_type = self.mime_type
|
||||
content_type = Redmine::MimeType.of(self.disk_filename) if content_type.blank?
|
||||
content_type = mime_type
|
||||
content_type = Redmine::MimeType.of(disk_filename) if content_type.blank?
|
||||
content_type = 'application/octet-stream' if content_type.blank?
|
||||
content_type.to_s
|
||||
end
|
||||
|
||||
def clone
|
||||
new_revision = DmsfFileRevision.new
|
||||
new_revision.dmsf_file = self.dmsf_file
|
||||
new_revision.disk_filename = self.disk_filename
|
||||
new_revision.size = self.size
|
||||
new_revision.mime_type = self.mime_type
|
||||
new_revision.title = self.title
|
||||
new_revision.description = self.description
|
||||
new_revision.workflow = self.workflow
|
||||
new_revision.major_version = self.major_version
|
||||
new_revision.minor_version = self.minor_version
|
||||
new_revision.dmsf_file = dmsf_file
|
||||
new_revision.disk_filename = disk_filename
|
||||
new_revision.size = size
|
||||
new_revision.mime_type = mime_type
|
||||
new_revision.title = title
|
||||
new_revision.description = description
|
||||
new_revision.workflow = workflow
|
||||
new_revision.major_version = major_version
|
||||
new_revision.minor_version = minor_version
|
||||
new_revision.source_revision = self
|
||||
new_revision.user = User.current
|
||||
new_revision.name = self.name
|
||||
new_revision.digest = self.digest
|
||||
new_revision.name = name
|
||||
new_revision.digest = digest
|
||||
new_revision
|
||||
end
|
||||
|
||||
def workflow_str(name)
|
||||
str = ''
|
||||
if name && dmsf_workflow_id
|
||||
wf = DmsfWorkflow.find_by_id(dmsf_workflow_id)
|
||||
str = "#{wf.name} - " if wf
|
||||
names = DmsfWorkflow.find_by(id: dmsf_workflow_id).pluck(:name)
|
||||
str = "#{names.first} - " if names.any?
|
||||
end
|
||||
case workflow
|
||||
when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
||||
@ -248,38 +248,38 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
if commit == 'start'
|
||||
self.workflow = DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
||||
self.dmsf_workflow_started_by = User.current.id if User.current
|
||||
self.dmsf_workflow_started_at = DateTime.now
|
||||
self.dmsf_workflow_started_at = DateTime.current
|
||||
else
|
||||
self.workflow = DmsfWorkflow::STATE_ASSIGNED
|
||||
self.dmsf_workflow_assigned_by = User.current.id if User.current
|
||||
self.dmsf_workflow_assigned_at = DateTime.now
|
||||
self.dmsf_workflow_assigned_at = DateTime.current
|
||||
end
|
||||
end
|
||||
|
||||
def assign_workflow(dmsf_workflow_id)
|
||||
wf = DmsfWorkflow.find_by_id(dmsf_workflow_id)
|
||||
wf = DmsfWorkflow.find_by(id: dmsf_workflow_id)
|
||||
wf.assign(self.id) if wf && self.id
|
||||
end
|
||||
|
||||
def increase_version(version_to_increase)
|
||||
self.minor_version = case version_to_increase
|
||||
when 1
|
||||
DmsfUploadHelper.increase_version(self.minor_version, 1)
|
||||
DmsfUploadHelper.increase_version(minor_version, 1)
|
||||
when 2
|
||||
(self.major_version < 0) ? -(' '.ord) : 0
|
||||
(major_version < 0) ? -(' '.ord) : 0
|
||||
else
|
||||
self.minor_version
|
||||
minor_version
|
||||
end
|
||||
self.major_version = case version_to_increase
|
||||
when 2
|
||||
DmsfUploadHelper::increase_version(self.major_version, 1)
|
||||
DmsfUploadHelper::increase_version(major_version, 1)
|
||||
else
|
||||
major_version
|
||||
end
|
||||
end
|
||||
|
||||
def copy_file_content(open_file)
|
||||
File.open(self.disk_file(false), 'wb') do |f|
|
||||
File.open(disk_file(false), 'wb') do |f|
|
||||
while (buffer = open_file.read(8192))
|
||||
f.write(buffer)
|
||||
end
|
||||
@ -292,25 +292,25 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def iversion
|
||||
parts = self.version.split '.'
|
||||
parts = version.split '.'
|
||||
parts.size == 2 ? parts[0].to_i * 1000 + parts[1].to_i : 0
|
||||
end
|
||||
|
||||
def formatted_name(format)
|
||||
return self.name if format.blank?
|
||||
if self.name =~ /(.*)(\..*)$/
|
||||
return name if format.blank?
|
||||
if name =~ /(.*)(\..*)$/
|
||||
filename = $1
|
||||
ext = $2
|
||||
else
|
||||
filename = self.name
|
||||
filename = name
|
||||
end
|
||||
format2 = format.dup
|
||||
format2.sub!('%t', self.title)
|
||||
format2.sub!('%t', title)
|
||||
format2.sub!('%f', filename)
|
||||
format2.sub!('%d', self.updated_at.strftime('%Y%m%d%H%M%S'))
|
||||
format2.sub!('%v', self.version)
|
||||
format2.sub!('%i', self.dmsf_file.id.to_s)
|
||||
format2.sub!('%r', self.id.to_s)
|
||||
format2.sub!('%d', updated_at.strftime('%Y%m%d%H%M%S'))
|
||||
format2.sub!('%v', version)
|
||||
format2.sub!('%i', dmsf_file.id.to_s)
|
||||
format2.sub!('%r', id.to_s)
|
||||
format2 += ext if ext
|
||||
format2
|
||||
end
|
||||
@ -325,33 +325,33 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def create_digest
|
||||
self.digest = DmsfFileRevision.create_digest(self.disk_file)
|
||||
self.digest = DmsfFileRevision.create_digest(disk_file)
|
||||
end
|
||||
|
||||
# Returns either MD5 or SHA256 depending on the way self.digest was computed
|
||||
def digest_type
|
||||
self.digest.size < 64 ? 'MD5' : 'SHA256' if digest.present?
|
||||
digest.size < 64 ? 'MD5' : 'SHA256' if digest.present?
|
||||
end
|
||||
|
||||
def tooltip
|
||||
if self.description.present?
|
||||
text = self.description
|
||||
if description.present?
|
||||
text = description
|
||||
else
|
||||
text = ''
|
||||
end
|
||||
if self.comment.present?
|
||||
if comment.present?
|
||||
text += ' / ' if text.present?
|
||||
text += self.comment
|
||||
text += comment
|
||||
end
|
||||
ActionView::Base.full_sanitizer.sanitize(text)
|
||||
end
|
||||
|
||||
def workflow_tooltip
|
||||
tooltip = ''
|
||||
if self.dmsf_workflow
|
||||
if dmsf_workflow
|
||||
case workflow
|
||||
when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL, DmsfWorkflow::STATE_ASSIGNED
|
||||
assignments = self.dmsf_workflow.next_assignments(self.id)
|
||||
assignments = dmsf_workflow.next_assignments(id)
|
||||
if assignments
|
||||
assignments.each_with_index do |assignment, index|
|
||||
tooltip << ', ' if index > 0
|
||||
@ -360,8 +360,8 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
when DmsfWorkflow::STATE_APPROVED, DmsfWorkflow::STATE_REJECTED
|
||||
action = DmsfWorkflowStepAction.joins(:dmsf_workflow_step_assignment).where(
|
||||
:dmsf_workflow_step_assignments => { :dmsf_file_revision_id => self.id }).order(
|
||||
'dmsf_workflow_step_actions.id').last
|
||||
:dmsf_workflow_step_assignments => { :dmsf_file_revision_id => id }).order(
|
||||
'dmsf_workflow_step_actions.created_at').last
|
||||
tooltip << action.author.name if action
|
||||
end
|
||||
end
|
||||
@ -370,7 +370,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
|
||||
def protocol
|
||||
unless @protocol
|
||||
@protocol = PROTOCOLS[self.mime_type]
|
||||
@protocol = PROTOCOLS[mime_type]
|
||||
end
|
||||
@protocol
|
||||
end
|
||||
|
||||
@ -26,7 +26,7 @@ class DmsfFileRevisionAccess < ActiveRecord::Base
|
||||
delegate :dmsf_file, :to => :dmsf_file_revision, :allow_nil => false
|
||||
delegate :project, :to => :dmsf_file, :allow_nil => false
|
||||
|
||||
validates_presence_of :dmsf_file_revision
|
||||
validates :dmsf_file_revision, presence: true
|
||||
|
||||
DownloadAction = 0
|
||||
EmailAction = 1
|
||||
@ -44,5 +44,5 @@ class DmsfFileRevisionAccess < ActiveRecord::Base
|
||||
:scope => DmsfFileRevisionAccess.
|
||||
joins(:dmsf_file_revision).joins("JOIN #{DmsfFile.table_name} ON dmsf_files.id = dmsf_file_revisions.dmsf_file_id").
|
||||
joins("JOIN #{Project.table_name} on dmsf_files.project_id = projects.id").
|
||||
where(:dmsf_files => { :deleted => DmsfFile::STATUS_ACTIVE })
|
||||
where(:dmsf_files => { deleted: DmsfFile::STATUS_ACTIVE })
|
||||
end
|
||||
|
||||
@ -35,7 +35,7 @@ class DmsfFileRevisionCustomField < CustomField
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
false
|
||||
else
|
||||
x == y
|
||||
end
|
||||
|
||||
@ -30,14 +30,14 @@ class DmsfFolder < ActiveRecord::Base
|
||||
|
||||
has_many :dmsf_folders, -> { order :title }, :dependent => :destroy
|
||||
has_many :dmsf_files, :dependent => :destroy
|
||||
has_many :folder_links, -> { where(:target_type => 'DmsfFolder').order(:name) },
|
||||
has_many :folder_links, -> { where(target_type: 'DmsfFolder').order(:name) },
|
||||
:class_name => 'DmsfLink', :foreign_key => 'dmsf_folder_id', :dependent => :destroy
|
||||
has_many :file_links, -> { where :target_type => 'DmsfFile' },
|
||||
has_many :file_links, -> { where(target_type: 'DmsfFile') },
|
||||
:class_name => 'DmsfLink', :foreign_key => 'dmsf_folder_id', :dependent => :destroy
|
||||
has_many :url_links, -> { where :target_type => 'DmsfUrl' },
|
||||
has_many :url_links, -> { where(target_type: 'DmsfUrl') },
|
||||
:class_name => 'DmsfLink', :foreign_key => 'dmsf_folder_id', :dependent => :destroy
|
||||
has_many :dmsf_links, :dependent => :destroy
|
||||
has_many :referenced_links, -> { where :target_type => 'DmsfFolder' },
|
||||
has_many :referenced_links, -> { where(target_type: 'DmsfFolder') },
|
||||
:class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy
|
||||
has_many :locks, -> { where(entity_type: 1).order("#{DmsfLock.table_name}.updated_at DESC") },
|
||||
:class_name => 'DmsfLock', :foreign_key => 'entity_id', :dependent => :destroy
|
||||
@ -67,18 +67,18 @@ class DmsfFolder < ActiveRecord::Base
|
||||
|
||||
scope :visible, -> (system=true) { joins(:project).joins(
|
||||
"LEFT JOIN #{DmsfFolderPermission.table_name} ON #{DmsfFolder.table_name}.id = #{DmsfFolderPermission.table_name}.dmsf_folder_id").where(
|
||||
:deleted => STATUS_ACTIVE).where(DmsfFolder.visible_condition(system)).distinct
|
||||
deleted: STATUS_ACTIVE).where(DmsfFolder.visible_condition(system)).distinct
|
||||
}
|
||||
scope :deleted, -> { joins(:project).joins(
|
||||
"LEFT JOIN #{DmsfFolderPermission.table_name} ON #{DmsfFolder.table_name}.id = #{DmsfFolderPermission.table_name}.dmsf_folder_id").where(
|
||||
:deleted => STATUS_DELETED).where(DmsfFolder.visible_condition).distinct
|
||||
deleted: STATUS_DELETED).where(DmsfFolder.visible_condition).distinct
|
||||
}
|
||||
scope :system, -> { where(:system => true) }
|
||||
scope :notsystem, -> { where(:system => false) }
|
||||
scope :system, -> { where(system: true) }
|
||||
scope :notsystem, -> { where(system: false) }
|
||||
|
||||
acts_as_customizable
|
||||
|
||||
acts_as_searchable :columns => ["#{self.table_name}.title", "#{self.table_name}.description"],
|
||||
acts_as_searchable :columns => ["#{table_name}.title", "#{table_name}.description"],
|
||||
:project_key => 'project_id',
|
||||
:date_column => 'updated_at',
|
||||
:permission => :view_dmsf_files,
|
||||
@ -90,13 +90,11 @@ class DmsfFolder < ActiveRecord::Base
|
||||
:datetime => Proc.new {|o| o.updated_at },
|
||||
:author => Proc.new {|o| o.user }
|
||||
|
||||
validates_presence_of :title, :project
|
||||
validates :title, presence: true, dmsf_file_name: true
|
||||
validates :project, presence: true
|
||||
validates_uniqueness_of :title, :scope => [:dmsf_folder_id, :project_id, :deleted],
|
||||
conditions: -> { where(:deleted => STATUS_ACTIVE) }
|
||||
validates_format_of :title, :with => /\A[^#{INVALID_CHARACTERS}]*\z/,
|
||||
:message => l(:error_contains_invalid_character)
|
||||
validate :check_cycle
|
||||
validates_length_of :description, :maximum => 65535
|
||||
conditions: -> { where(deleted: STATUS_ACTIVE) }
|
||||
validates :description, length: { maximum: 65535 }
|
||||
|
||||
before_create :default_values
|
||||
|
||||
@ -105,7 +103,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
return true if (User.current.admin? || folder.nil?)
|
||||
# System folder?
|
||||
if folder && folder.system
|
||||
return false if !(allow_system || User.current.allowed_to?(:display_system_folders, folder.project))
|
||||
return false unless allow_system || User.current.allowed_to?(:display_system_folders, folder.project)
|
||||
return false if folder.issue && !folder.issue.visible?(User.current)
|
||||
end
|
||||
# Permissions?
|
||||
@ -125,61 +123,48 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def default_values
|
||||
if Setting.plugin_redmine_dmsf['dmsf_default_notifications'] == '1' && !self.system
|
||||
if Setting.plugin_redmine_dmsf['dmsf_default_notifications'] == '1' && !system
|
||||
self.notification = true
|
||||
end
|
||||
end
|
||||
|
||||
def check_cycle
|
||||
folders = []
|
||||
self.dmsf_folders.each {|f| folders.push(f)}
|
||||
self.dmsf_folders.each do |folder|
|
||||
if folder == self.dmsf_folder
|
||||
errors.add(:folder, l(:error_create_cycle_in_folder_dependency))
|
||||
return false
|
||||
end
|
||||
folder.dmsf_folders.each {|f| folders.push(f)}
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def self.find_by_title(project, folder, title)
|
||||
if folder
|
||||
visible.where(:project_id => project.id, :dmsf_folder_id => nil, :title => title).first
|
||||
visible.where(project_id: project.id, dmsf_folder_id: nil, title: title).first
|
||||
else
|
||||
visible.where(:project_id => project.id, :dmsf_folder_id => folder.id, :title => title).first
|
||||
visible.where(project_id: project.id, dmsf_folder_id: folder.id, title: title).first
|
||||
end
|
||||
end
|
||||
|
||||
def delete(commit)
|
||||
if self.locked?
|
||||
if locked?
|
||||
errors[:base] << l(:error_folder_is_locked)
|
||||
return false
|
||||
elsif !self.dmsf_folders.visible.empty? || !self.dmsf_files.visible.empty? || !self.dmsf_links.visible.empty?
|
||||
elsif !dmsf_folders.visible.empty? || !dmsf_files.visible.empty? || !dmsf_links.visible.empty?
|
||||
errors[:base] << l(:error_folder_is_not_empty)
|
||||
return false
|
||||
end
|
||||
if commit
|
||||
self.destroy
|
||||
destroy
|
||||
else
|
||||
self.deleted = STATUS_DELETED
|
||||
self.deleted_by_user = User.current
|
||||
self.save
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
def deleted?
|
||||
self.deleted == STATUS_DELETED
|
||||
deleted == STATUS_DELETED
|
||||
end
|
||||
|
||||
def restore
|
||||
if self.dmsf_folder_id && (self.dmsf_folder.nil? || self.dmsf_folder.deleted?)
|
||||
if dmsf_folder_id && (nil? || dmsf_folder.deleted?)
|
||||
errors[:base] << l(:error_parent_folder)
|
||||
return false
|
||||
end
|
||||
self.deleted = STATUS_ACTIVE
|
||||
self.deleted_by_user = nil
|
||||
self.save
|
||||
save!
|
||||
end
|
||||
|
||||
def dmsf_path
|
||||
@ -193,34 +178,31 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def dmsf_path_str
|
||||
path = self.dmsf_path
|
||||
path = dmsf_path
|
||||
string_path = path.map { |element| element.title }
|
||||
string_path.join('/')
|
||||
end
|
||||
|
||||
def notify?
|
||||
return true if self.notification
|
||||
return true if self.dmsf_folder && self.dmsf_folder.notify?
|
||||
return true if !self.dmsf_folder && self.project.dmsf_notification
|
||||
return false
|
||||
return true if notification
|
||||
return true if dmsf_folder && dmsf_folder.notify?
|
||||
return true if !dmsf_folder && project.dmsf_notification
|
||||
false
|
||||
end
|
||||
|
||||
def notify_deactivate
|
||||
self.notification = nil
|
||||
self.save!
|
||||
save!
|
||||
end
|
||||
|
||||
def notify_activate
|
||||
self.notification = true
|
||||
self.save!
|
||||
save!
|
||||
end
|
||||
|
||||
def self.directory_tree(project, current_folder = nil)
|
||||
unless project.is_a? Project
|
||||
project = Project.find_by_id project
|
||||
end
|
||||
tree = [[l(:link_documents), nil]]
|
||||
folders = DmsfFolder.where(:project_id => project.id).visible(false).to_a
|
||||
folders = DmsfFolder.where(project_id: project.id).visible(false).to_a
|
||||
folders.delete(current_folder)
|
||||
folders = folders.delete_if{ |f| f.locked_for_user? }
|
||||
folders.each do |folder|
|
||||
@ -231,9 +213,9 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def folder_tree
|
||||
tree = [[self.title, self.id]]
|
||||
tree = [[title, id]]
|
||||
DmsfFolder.directory_subtree(tree, self, 1, nil)
|
||||
return tree
|
||||
tree
|
||||
end
|
||||
|
||||
def self.file_list(files)
|
||||
@ -246,21 +228,21 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def deep_file_count
|
||||
file_count = self.dmsf_files.visible.count
|
||||
self.dmsf_folders.visible.each { |subfolder| file_count += subfolder.deep_file_count }
|
||||
file_count + self.file_links.visible.count + self.url_links.visible.count
|
||||
file_count = dmsf_files.visible.all.size
|
||||
dmsf_folders.visible.each { |subfolder| file_count += subfolder.deep_file_count }
|
||||
file_count + file_links.visible.all.size + url_links.visible.all.size
|
||||
end
|
||||
|
||||
def deep_folder_count
|
||||
folder_count = self.dmsf_folders.visible.count
|
||||
self.dmsf_folders.visible.each { |subfolder| folder_count += subfolder.deep_folder_count }
|
||||
folder_count + self.folder_links.visible.count
|
||||
folder_count = dmsf_folders.visible.all.size
|
||||
dmsf_folders.visible.each { |subfolder| folder_count += subfolder.deep_folder_count }
|
||||
folder_count + folder_links.visible.all.size
|
||||
end
|
||||
|
||||
def deep_size
|
||||
size = 0
|
||||
self.dmsf_files.visible.each {|file| size += file.size}
|
||||
self.dmsf_folders.visible.each {|subfolder| size += subfolder.deep_size}
|
||||
dmsf_files.visible.each {|file| size += file.size}
|
||||
dmsf_folders.visible.each {|subfolder| size += subfolder.deep_size}
|
||||
size
|
||||
end
|
||||
|
||||
@ -282,42 +264,42 @@ class DmsfFolder < ActiveRecord::Base
|
||||
new_folder = DmsfFolder.new
|
||||
new_folder.dmsf_folder = folder ? folder : nil
|
||||
new_folder.project = folder ? folder.project : project
|
||||
new_folder.title = self.title
|
||||
new_folder.description = self.description
|
||||
new_folder.title = title
|
||||
new_folder.description = description
|
||||
new_folder.user = User.current
|
||||
|
||||
new_folder.custom_values = []
|
||||
self.custom_values.each do |cv|
|
||||
custom_values.each do |cv|
|
||||
new_folder.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
||||
end
|
||||
|
||||
return new_folder unless new_folder.save
|
||||
|
||||
self.dmsf_files.visible.each do |f|
|
||||
dmsf_files.visible.each do |f|
|
||||
f.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.dmsf_folders.visible.each do |s|
|
||||
dmsf_folders.visible.each do |s|
|
||||
s.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.folder_links.visible.each do |l|
|
||||
folder_links.visible.each do |l|
|
||||
l.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.file_links.visible.each do |l|
|
||||
file_links.visible.each do |l|
|
||||
l.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.url_links.visible.each do |l|
|
||||
url_links.visible.each do |l|
|
||||
l.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.dmsf_folder_permissions.each do |p|
|
||||
dmsf_folder_permissions.each do |p|
|
||||
p.copy_to new_folder
|
||||
end
|
||||
|
||||
return new_folder
|
||||
new_folder
|
||||
end
|
||||
|
||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||
@ -329,24 +311,24 @@ class DmsfFolder < ActiveRecord::Base
|
||||
last_update = updated_at
|
||||
time = DmsfFolder.where(
|
||||
['project_id = ? AND dmsf_folder_id = ? AND updated_at > ?',
|
||||
self.project_id, self.id, last_update]).maximum(:updated_at)
|
||||
project_id, id, last_update]).maximum(:updated_at)
|
||||
last_update = time if time
|
||||
time = DmsfFile.where(
|
||||
['project_id = ? AND dmsf_folder_id = ? AND updated_at > ?',
|
||||
self.project_id, self.id, last_update]).maximum(:updated_at)
|
||||
project_id, id, last_update]).maximum(:updated_at)
|
||||
last_update = time if time
|
||||
time = DmsfLink.where(
|
||||
['project_id = ? AND dmsf_folder_id = ? AND updated_at > ?',
|
||||
self.project_id, self.id, last_update]).maximum(:updated_at)
|
||||
project_id, id, last_update]).maximum(:updated_at)
|
||||
last_update = time if time
|
||||
last_update
|
||||
end
|
||||
|
||||
# Number of items in the folder
|
||||
def items
|
||||
dmsf_folders.visible.where(:project_id => self.project_id).count +
|
||||
dmsf_files.visible.where(:project_id => self.project_id).count +
|
||||
dmsf_links.visible.where(:project_id => self.project_id).count
|
||||
dmsf_folders.visible.where(project_id: project_id).all.size +
|
||||
dmsf_files.visible.where(project_id: project_id).all.size +
|
||||
dmsf_links.visible.where(project_id: project_id).all.size
|
||||
end
|
||||
|
||||
def self.is_column_on?(column)
|
||||
@ -356,7 +338,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def custom_value(custom_field)
|
||||
self.custom_field_values.each do |cv|
|
||||
custom_field_values.each do |cv|
|
||||
return cv.value if cv.custom_field == custom_field
|
||||
end
|
||||
nil
|
||||
@ -424,8 +406,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
return nil if column == 'author'
|
||||
end
|
||||
# 9 - custom fields
|
||||
cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField')
|
||||
cfs.each do |c|
|
||||
CustomField.where(type: 'DmsfFileRevisionCustomField').each do |c|
|
||||
if DmsfFolder.is_column_on?(c.name)
|
||||
pos += 1
|
||||
end
|
||||
@ -457,44 +438,43 @@ class DmsfFolder < ActiveRecord::Base
|
||||
def to_csv(columns, level)
|
||||
csv = []
|
||||
# Project
|
||||
csv << self.project.name if columns.include?(l(:field_project))
|
||||
csv << project.name if columns.include?(l(:field_project))
|
||||
# Id
|
||||
csv << self.id if columns.include?('id')
|
||||
csv << id if columns.include?('id')
|
||||
# Title
|
||||
csv << self.title.insert(0, ' ' * level) if columns.include?('title')
|
||||
csv << title.insert(0, ' ' * level) if columns.include?('title')
|
||||
# Extension
|
||||
csv << '' if columns.include?('extension')
|
||||
# Size
|
||||
csv << '' if columns.include?('size')
|
||||
# Modified
|
||||
csv << format_time(self.updated_at) if columns.include?('modified')
|
||||
csv << format_time(updated_at) if columns.include?('modified')
|
||||
# Version
|
||||
csv << '' if columns.include?('version')
|
||||
# Workflow
|
||||
csv << '' if columns.include?('workflow')
|
||||
# Author
|
||||
csv << self.user.name if columns.include?('author')
|
||||
csv << user.name if columns.include?('author')
|
||||
# Last approver
|
||||
csv << '' if columns.include?(l(:label_last_approver))
|
||||
# Url
|
||||
if columns.include?(l(:label_document_url))
|
||||
default_url_options[:host] = Setting.host_name
|
||||
csv << url_for(:controller => :dmsf, :action => 'show', :id => self.project_id, :folder_id => self.id)
|
||||
csv << url_for(:controller => :dmsf, :action => 'show', :id => project_id, :folder_id => id)
|
||||
end
|
||||
# Revision
|
||||
csv << '' if columns.include?(l(:label_last_revision_id))
|
||||
# Custom fields
|
||||
cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position)
|
||||
cfs.each do |c|
|
||||
csv << self.custom_value(c) if columns.include?(c.name)
|
||||
CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c|
|
||||
csv << custom_value(c) if columns.include?(c.name)
|
||||
end
|
||||
csv
|
||||
end
|
||||
|
||||
def get_locked_title
|
||||
if self.locked_for_user?
|
||||
if self.lock.reverse[0].user
|
||||
return l(:title_locked_by_user, :user => self.lock.reverse[0].user)
|
||||
if locked_for_user?
|
||||
if lock.reverse[0].user
|
||||
return l(:title_locked_by_user, :user => lock.reverse[0].user)
|
||||
else
|
||||
return l(:notice_account_unknown_email)
|
||||
end
|
||||
@ -504,9 +484,9 @@ class DmsfFolder < ActiveRecord::Base
|
||||
|
||||
def issue
|
||||
unless @issue
|
||||
if self.system
|
||||
issue_id = self.title.to_i
|
||||
@issue = Issue.find_by_id(issue_id) if issue_id > 0
|
||||
if system
|
||||
issue_id = title.to_i
|
||||
@issue = Issue.find_by(id: issue_id) if issue_id > 0
|
||||
end
|
||||
end
|
||||
@issue
|
||||
@ -520,18 +500,18 @@ class DmsfFolder < ActiveRecord::Base
|
||||
# Custom fields
|
||||
if params[:dmsf_folder][:custom_field_values].present?
|
||||
params[:dmsf_folder][:custom_field_values].each_with_index do |v, i|
|
||||
self.custom_field_values[i].value = v[1]
|
||||
custom_field_values[i].value = v[1]
|
||||
end
|
||||
end
|
||||
# Permissions
|
||||
self.dmsf_folder_permissions.delete_all
|
||||
dmsf_folder_permissions.delete_all
|
||||
if params[:permissions]
|
||||
if params[:permissions][:role_ids]
|
||||
params[:permissions][:role_ids].each do |role_id|
|
||||
permission = DmsfFolderPermission.new
|
||||
permission.object_id = role_id
|
||||
permission.object_type = Role.model_name.to_s
|
||||
self.dmsf_folder_permissions << permission
|
||||
dmsf_folder_permissions << permission
|
||||
end
|
||||
end
|
||||
if params[:permissions][:user_ids]
|
||||
@ -539,12 +519,12 @@ class DmsfFolder < ActiveRecord::Base
|
||||
permission = DmsfFolderPermission.new
|
||||
permission.object_id = user_id
|
||||
permission.object_type = User.model_name.to_s
|
||||
self.dmsf_folder_permissions << permission
|
||||
dmsf_folder_permissions << permission
|
||||
end
|
||||
end
|
||||
end
|
||||
# Save
|
||||
self.save
|
||||
save!
|
||||
end
|
||||
|
||||
def self.get_valid_title(title)
|
||||
@ -557,7 +537,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def self.directory_subtree(tree, folder, level, current_folder)
|
||||
folders = DmsfFolder.where(:project_id => folder.project_id, :dmsf_folder_id => folder.id).notsystem.visible(false).to_a
|
||||
folders = DmsfFolder.where(project_id: folder.project_id, dmsf_folder_id: folder.id).notsystem.visible(false).to_a
|
||||
folders.delete(current_folder)
|
||||
folders.delete_if { |f| f.locked_for_user? }
|
||||
folders.each do |subfolder|
|
||||
|
||||
@ -22,17 +22,17 @@ class DmsfFolderPermission < ActiveRecord::Base
|
||||
|
||||
belongs_to :dmsf_folder
|
||||
|
||||
validates_presence_of :dmsf_folder
|
||||
validates :dmsf_folder, presence: true
|
||||
|
||||
scope :users, -> { where(:object_type => User.model_name.to_s) }
|
||||
scope :roles, -> { where(:object_type => Role.model_name.to_s) }
|
||||
scope :users, -> { where(object_type: User.model_name.to_s) }
|
||||
scope :roles, -> { where(object_type: Role.model_name.to_s) }
|
||||
|
||||
def copy_to(folder)
|
||||
permission = DmsfFolderPermission.new
|
||||
permission.dmsf_folder_id = folder.id
|
||||
permission.object_id = self.object_id
|
||||
permission.object_type = self.object_type
|
||||
permission.save
|
||||
permission.object_id = object_id
|
||||
permission.object_type = object_type
|
||||
permission.save!
|
||||
permission
|
||||
end
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# encode: utf-8
|
||||
# encode: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
@ -27,57 +27,43 @@ class DmsfLink < ActiveRecord::Base
|
||||
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :name, :project
|
||||
validates_length_of :name, :maximum => 255
|
||||
validates_length_of :external_url, :maximum => 255
|
||||
validate :validate_url
|
||||
|
||||
def validate_url
|
||||
if self.target_type == 'DmsfUrl'
|
||||
begin
|
||||
if self.external_url.present?
|
||||
URI.parse self.external_url
|
||||
else
|
||||
errors.add :external_url, :invalid
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
errors.add :external_url, :invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
validates :name, presence: true, length: { maximum: 255 }
|
||||
validates :project, presence: true
|
||||
validates :external_url, length: { maximum: 255 }
|
||||
validates :external_url, dmsf_url: true
|
||||
|
||||
STATUS_DELETED = 1
|
||||
STATUS_ACTIVE = 0
|
||||
|
||||
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
|
||||
scope :visible, -> { where(deleted: STATUS_ACTIVE) }
|
||||
scope :deleted, -> { where(deleted: STATUS_DELETED) }
|
||||
|
||||
def target_folder_id
|
||||
if self.target_type == DmsfFolder.model_name.to_s
|
||||
self.target_id
|
||||
if target_type == DmsfFolder.model_name.to_s
|
||||
target_id
|
||||
else
|
||||
f = DmsfFile.find_by_id self.target_id
|
||||
f.dmsf_folder_id if f
|
||||
dmsf_folder_ids = DmsfFile.where(id: target_id).pluck(:dmsf_folder_id)
|
||||
dmsf_folder_ids.first
|
||||
end
|
||||
end
|
||||
|
||||
def target_folder
|
||||
unless @target_folder
|
||||
if self.target_folder_id
|
||||
@target_folder = DmsfFolder.find_by_id self.target_folder_id
|
||||
if target_folder_id
|
||||
@target_folder = DmsfFolder.find_by(id: target_folder_id)
|
||||
end
|
||||
end
|
||||
@target_folder
|
||||
end
|
||||
|
||||
def target_file_id
|
||||
self.target_id if self.target_type == DmsfFile.model_name.to_s
|
||||
target_id if target_type == DmsfFile.model_name.to_s
|
||||
end
|
||||
|
||||
def target_file
|
||||
unless @target_file
|
||||
if self.target_file_id
|
||||
@target_file = DmsfFile.find_by_id self.target_file_id
|
||||
if target_file_id
|
||||
@target_file = DmsfFile.find_by(id: target_file_id)
|
||||
end
|
||||
end
|
||||
@target_file
|
||||
@ -85,22 +71,20 @@ class DmsfLink < ActiveRecord::Base
|
||||
|
||||
def target_project
|
||||
unless @target_project
|
||||
@target_project = Project.find_by_id self.target_project_id
|
||||
@target_project = Project.find_by(id: target_project_id)
|
||||
end
|
||||
@target_project
|
||||
end
|
||||
|
||||
def folder
|
||||
unless @folder
|
||||
if self.dmsf_folder_id
|
||||
@folder = DmsfFolder.find_by_id self.dmsf_folder_id
|
||||
end
|
||||
if !@folder && dmsf_folder_id
|
||||
@folder = DmsfFolder.find_by(id: dmsf_folder_id)
|
||||
end
|
||||
@folder
|
||||
end
|
||||
|
||||
def title
|
||||
self.name
|
||||
name
|
||||
end
|
||||
|
||||
def self.find_link_by_file_name(project, folder, filename)
|
||||
@ -115,12 +99,12 @@ class DmsfLink < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def path
|
||||
if self.target_type == DmsfFile.model_name.to_s
|
||||
path = self.target_file.dmsf_path.map { |element| element.is_a?(DmsfFile) ? element.display_name : element.title }.join('/') if self.target_file
|
||||
if target_type == DmsfFile.model_name.to_s
|
||||
path = target_file.dmsf_path.map { |element| element.is_a?(DmsfFile) ? element.display_name : element.title }.join('/') if target_file
|
||||
else
|
||||
path = self.target_folder ? self.target_folder.dmsf_path_str : ''
|
||||
path = target_folder ? target_folder.dmsf_path_str : ''
|
||||
end
|
||||
path.insert(0, "#{self.target_project.name}:") if self.project_id != self.target_project_id
|
||||
path.insert(0, "#{target_project.name}:") if project_id != target_project_id
|
||||
if path && path.length > 50
|
||||
return "#{path[0, 25]}...#{path[-25, 25]}"
|
||||
end
|
||||
@ -129,29 +113,29 @@ class DmsfLink < ActiveRecord::Base
|
||||
|
||||
def copy_to(project, folder)
|
||||
link = DmsfLink.new
|
||||
link.target_project_id = self.target_project_id
|
||||
link.target_id = self.target_id
|
||||
link.target_type = self.target_type
|
||||
link.name = self.name
|
||||
link.external_url = self.external_url
|
||||
link.target_project_id = target_project_id
|
||||
link.target_id = target_id
|
||||
link.target_type = target_type
|
||||
link.name = name
|
||||
link.external_url = external_url
|
||||
link.project_id = project.id
|
||||
link.dmsf_folder_id = folder ? folder.id : nil
|
||||
link.save
|
||||
link.save!
|
||||
link
|
||||
end
|
||||
|
||||
def container
|
||||
if self.folder && self.folder.system
|
||||
Issue.where(:id => self.folder.title.to_i).first
|
||||
if folder && folder.system
|
||||
Issue.find_by(id: folder.title)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(commit = false)
|
||||
if commit
|
||||
if self.container.is_a?(Issue)
|
||||
self.container.dmsf_file_removed(self.target_file)
|
||||
if container.is_a?(Issue)
|
||||
container.dmsf_file_removed(target_file)
|
||||
end
|
||||
self.destroy
|
||||
destroy
|
||||
else
|
||||
self.deleted = STATUS_DELETED
|
||||
self.deleted_by_user = User.current
|
||||
@ -160,7 +144,7 @@ class DmsfLink < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def restore
|
||||
if self.dmsf_folder_id && (self.dmsf_folder.nil? || self.dmsf_folder.deleted?)
|
||||
if dmsf_folder_id && (dmsf_folder.nil? || dmsf_folder.deleted?)
|
||||
errors[:base] << l(:error_parent_folder)
|
||||
return false
|
||||
end
|
||||
@ -170,7 +154,7 @@ class DmsfLink < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def is_folder?
|
||||
self.target_type == 'DmsfFolder'
|
||||
target_type == 'DmsfFolder'
|
||||
end
|
||||
|
||||
def is_file?
|
||||
@ -179,34 +163,33 @@ class DmsfLink < ActiveRecord::Base
|
||||
|
||||
def to_csv(columns, level)
|
||||
csv = []
|
||||
if self.target_type == 'DmsfUrl'
|
||||
if target_type == 'DmsfUrl'
|
||||
# Project
|
||||
csv << self.project.name if columns.include?(l(:field_project))
|
||||
csv << project.name if columns.include?(l(:field_project))
|
||||
# Id
|
||||
csv << self.id if columns.include?('id')
|
||||
csv << id if columns.include?('id')
|
||||
# Title
|
||||
csv << self.title.insert(0, ' ' * level) if columns.include?('title')
|
||||
csv << title.insert(0, ' ' * level) if columns.include?('title')
|
||||
# Extension
|
||||
csv << '' if columns.include?('extension')
|
||||
# Size
|
||||
csv << '' if columns.include?('size')
|
||||
# Modified
|
||||
csv << format_time(self.updated_at) if columns.include?('modified')
|
||||
csv << format_time(updated_at) if columns.include?('modified')
|
||||
# Version
|
||||
csv << '' if columns.include?('version')
|
||||
# Workflow
|
||||
csv << '' if columns.include?('workflow')
|
||||
# Author
|
||||
csv << self.user.name if columns.include?('author')
|
||||
csv << user.name if columns.include?('author')
|
||||
# Last approver
|
||||
csv << '' if columns.include?(l(:label_last_approver))
|
||||
# Url
|
||||
csv << self.external_url if columns.include?(l(:label_document_url))
|
||||
csv << external_url if columns.include?(l(:label_document_url))
|
||||
# Revision
|
||||
csv << '' if columns.include?(l(:label_last_revision_id))
|
||||
# Custom fields
|
||||
cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position)
|
||||
cfs.each do |c|
|
||||
CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c|
|
||||
csv << '' if columns.include?(c.name)
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,7 +46,7 @@ class DmsfLock < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def expired?
|
||||
return expires_at && (expires_at <= Time.now)
|
||||
expires_at && (expires_at <= Time.current)
|
||||
end
|
||||
|
||||
def generate_uuid
|
||||
@ -65,7 +65,7 @@ class DmsfLock < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.find_by_param(*args)
|
||||
self.find(*args)
|
||||
find(*args)
|
||||
end
|
||||
|
||||
end
|
||||
@ -50,7 +50,7 @@ class DmsfMailer < Mailer
|
||||
end
|
||||
end
|
||||
|
||||
def send_documents(project, user, email_params)
|
||||
def send_documents(project, email_params)
|
||||
redmine_headers 'Project' => project.identifier if project
|
||||
@body = email_params[:body]
|
||||
@links_only = email_params[:links_only] == '1'
|
||||
|
||||
@ -36,7 +36,7 @@ class DmsfUpload
|
||||
attr_accessor :tempfile_path
|
||||
|
||||
def disk_file
|
||||
DmsfHelper.temp_dir.join(self.disk_filename).to_s
|
||||
DmsfHelper.temp_dir.join(disk_filename).to_s
|
||||
end
|
||||
|
||||
def self.create_from_uploaded_attachment(project, folder, uploaded_file)
|
||||
|
||||
@ -23,39 +23,11 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
belongs_to :author, :class_name => 'User'
|
||||
|
||||
scope :sorted, lambda { order(:name => :asc) }
|
||||
scope :global, lambda { where(:project_id => nil) }
|
||||
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
||||
scope :global, lambda { where(project_id: nil) }
|
||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||
scope :status, lambda { |arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||
|
||||
validate :name_validation
|
||||
validates_presence_of :name
|
||||
validates_length_of :name, :maximum => 255
|
||||
|
||||
def name_validation
|
||||
if self.project_id
|
||||
if self.id
|
||||
if (DmsfWorkflow.where(['(project_id IS NULL OR (project_id = ? AND id != ?)) AND name = ?',
|
||||
self.project_id, self.id, self.name]).exists?)
|
||||
errors.add(:name, l('activerecord.errors.messages.taken'))
|
||||
end
|
||||
else
|
||||
if (DmsfWorkflow.where(['(project_id IS NULL OR project_id = ?) AND name = ?',
|
||||
self.project_id, self.name]).exists?)
|
||||
errors.add(:name, l('activerecord.errors.messages.taken'))
|
||||
end
|
||||
end
|
||||
else
|
||||
if self.id
|
||||
if DmsfWorkflow.where(['name = ? AND id != ?', self.name, self.id]).exists?
|
||||
errors.add(:name, l('activerecord.errors.messages.taken'))
|
||||
end
|
||||
else
|
||||
if DmsfWorkflow.where(:name => self.name).exists?
|
||||
errors.add(:name, l('activerecord.errors.messages.taken'))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
validates :name, presence: true, length: { maximum: 255 }, dmsf_workflow_name: true
|
||||
|
||||
STATE_ASSIGNED = 3
|
||||
STATE_WAITING_FOR_APPROVAL = 1
|
||||
@ -68,18 +40,18 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
|
||||
def participiants
|
||||
users = Array.new
|
||||
self.dmsf_workflow_steps.each do |step|
|
||||
dmsf_workflow_steps.each do |step|
|
||||
users << step.user unless users.include? step.user
|
||||
end
|
||||
users
|
||||
end
|
||||
|
||||
def self.workflows(project)
|
||||
project ? where(:project_id => project) : where('project_id IS NULL')
|
||||
where(project_id: project)
|
||||
end
|
||||
|
||||
def project
|
||||
Project.find_by_id(project_id) if project_id
|
||||
Project.find_by(id: project_id) if project_id
|
||||
end
|
||||
|
||||
def to_s
|
||||
@ -100,7 +72,7 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
def delegates(q, dmsf_workflow_step_assignment_id, dmsf_file_revision_id)
|
||||
@ -123,32 +95,30 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
|
||||
def next_assignments(dmsf_file_revision_id)
|
||||
results = Array.new
|
||||
nsteps = self.dmsf_workflow_steps.collect{|s| s.step}.uniq
|
||||
nsteps = dmsf_workflow_steps.collect{ |s| s.step }.uniq
|
||||
nsteps.each do |i|
|
||||
step_is_finished = false
|
||||
steps = self.dmsf_workflow_steps.collect{|s| s.step == i ? s : nil}.compact
|
||||
steps = dmsf_workflow_steps.collect{ |s| s.step == i ? s : nil }.compact
|
||||
steps.each do |step|
|
||||
step.dmsf_workflow_step_assignments.each do |assignment|
|
||||
if assignment.dmsf_file_revision_id == dmsf_file_revision_id
|
||||
assignment.dmsf_workflow_step_actions.each do |action|
|
||||
case action.action
|
||||
when DmsfWorkflowStepAction::ACTION_APPROVE
|
||||
step_is_finished = true
|
||||
# Try to find another unfinished AND step
|
||||
exists = false
|
||||
stps = self.dmsf_workflow_steps.collect{|s| (s.step == i && s.operator == DmsfWorkflowStep::OPERATOR_AND) ? s : nil}.compact
|
||||
stps.each do |s|
|
||||
s.dmsf_workflow_step_assignments.each do |a|
|
||||
exists = a.add?(dmsf_file_revision_id)
|
||||
break if exists
|
||||
end
|
||||
step.dmsf_workflow_step_assignments.where(dmsf_file_revision_id: dmsf_file_revision_id).find_each do |assignment|
|
||||
assignment.dmsf_workflow_step_actions.find_each do |action|
|
||||
case action.action
|
||||
when DmsfWorkflowStepAction::ACTION_APPROVE
|
||||
step_is_finished = true
|
||||
# Try to find another unfinished AND step
|
||||
exists = false
|
||||
stps = dmsf_workflow_steps.collect{ |s| (s.step == i && s.operator == DmsfWorkflowStep::OPERATOR_AND) ? s : nil }.compact
|
||||
stps.each do |s|
|
||||
s.dmsf_workflow_step_assignments.where(dmsf_file_revision_id: dmsf_file_revision_id).find_each do |a|
|
||||
exists = a.add?(dmsf_file_revision_id)
|
||||
break if exists
|
||||
end
|
||||
step_is_finished = false if exists
|
||||
break
|
||||
when DmsfWorkflowStepAction::ACTION_REJECT
|
||||
return Array.new
|
||||
break if exists
|
||||
end
|
||||
step_is_finished = false if exists
|
||||
break
|
||||
when DmsfWorkflowStepAction::ACTION_REJECT
|
||||
return Array.new
|
||||
end
|
||||
end
|
||||
break if step_is_finished
|
||||
@ -157,7 +127,7 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
end
|
||||
unless step_is_finished
|
||||
steps.each do |step|
|
||||
step.dmsf_workflow_step_assignments.each do |assignment|
|
||||
step.dmsf_workflow_step_assignments.find_each do |assignment|
|
||||
results << assignment if assignment.add?(dmsf_file_revision_id)
|
||||
end
|
||||
end
|
||||
@ -175,50 +145,53 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
|
||||
def try_finish(revision, action, user_id)
|
||||
case action.action
|
||||
when DmsfWorkflowStepAction::ACTION_APPROVE
|
||||
assignments = self.next_assignments revision.id
|
||||
when DmsfWorkflowStepAction::ACTION_APPROVE
|
||||
assignments = next_assignments(revision.id)
|
||||
return false unless assignments.empty?
|
||||
revision.update_attribute(:workflow, DmsfWorkflow::STATE_APPROVED)
|
||||
revision.workflow = DmsfWorkflow::STATE_APPROVED
|
||||
revision.save!
|
||||
return true
|
||||
when DmsfWorkflowStepAction::ACTION_REJECT
|
||||
revision.update_attribute(:workflow, DmsfWorkflow::STATE_REJECTED)
|
||||
revision.workflow = DmsfWorkflow::STATE_REJECTED
|
||||
revision.save!
|
||||
return true
|
||||
when DmsfWorkflowStepAction::ACTION_DELEGATE
|
||||
self.dmsf_workflow_steps.each do |step|
|
||||
dmsf_workflow_steps.each do |step|
|
||||
step.dmsf_workflow_step_assignments.each do |assignment|
|
||||
if assignment.id == action.dmsf_workflow_step_assignment_id
|
||||
assignment.update_attribute(:user_id, user_id)
|
||||
assignment.user_id = user_id
|
||||
assignment.save!
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
def copy_to(project, name = nil)
|
||||
new_wf = self.dup
|
||||
new_wf = dup
|
||||
new_wf.name = name if name
|
||||
new_wf.project_id = project ? project.id : nil
|
||||
new_wf.author = User.current
|
||||
if new_wf.save
|
||||
self.dmsf_workflow_steps.each do |step|
|
||||
dmsf_workflow_steps.each do |step|
|
||||
step.copy_to(new_wf)
|
||||
end
|
||||
end
|
||||
return new_wf
|
||||
new_wf
|
||||
end
|
||||
|
||||
def locked?
|
||||
self.status == STATUS_LOCKED
|
||||
status == STATUS_LOCKED
|
||||
end
|
||||
|
||||
def active?
|
||||
self.status == STATUS_ACTIVE
|
||||
status == STATUS_ACTIVE
|
||||
end
|
||||
|
||||
def notify_users(project, revision, controller)
|
||||
assignments = self.next_assignments revision.id
|
||||
assignments = next_assignments(revision.id)
|
||||
recipients = assignments.collect{ |a| a.user }
|
||||
recipients.uniq!
|
||||
recipients = recipients & DmsfMailer.get_notify_users(project, [revision.dmsf_file], true)
|
||||
@ -231,7 +204,7 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
:text_email_started,
|
||||
:text_email_to_proceed).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients'] == '1'
|
||||
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
|
||||
unless recipients.blank?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
|
||||
@ -24,15 +24,18 @@ class DmsfWorkflowStep < ActiveRecord::Base
|
||||
|
||||
has_many :dmsf_workflow_step_assignments, :dependent => :destroy
|
||||
|
||||
validates_presence_of :dmsf_workflow, :step, :user, :operator
|
||||
validates_uniqueness_of :user_id, :scope => [:dmsf_workflow_id, :step]
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates :dmsf_workflow, presence: true
|
||||
validates :step, presence: true
|
||||
validates :user, presence: true
|
||||
validates :operator, presence: true
|
||||
validates_uniqueness_of :user_id, scope: [:dmsf_workflow_id, :step]
|
||||
validates :name, length: { maximum: 30 }
|
||||
|
||||
OPERATOR_OR = 0
|
||||
OPERATOR_AND = 1
|
||||
|
||||
def soperator
|
||||
DmsfWorkflowStep.soperator(self.operator)
|
||||
DmsfWorkflowStep.soperator(operator)
|
||||
end
|
||||
|
||||
def self.soperator(operator)
|
||||
@ -40,15 +43,15 @@ class DmsfWorkflowStep < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def assign(dmsf_file_revision_id)
|
||||
step_assignment = DmsfWorkflowStepAssignment.new(
|
||||
:dmsf_workflow_step_id => id,
|
||||
:user_id => user_id,
|
||||
:dmsf_file_revision_id => dmsf_file_revision_id)
|
||||
step_assignment.save
|
||||
step_assignment = DmsfWorkflowStepAssignment.new
|
||||
step_assignment.dmsf_workflow_step_id = id
|
||||
step_assignment.user_id = user_id
|
||||
step_assignment.dmsf_file_revision_id = dmsf_file_revision_id
|
||||
step_assignment.save!
|
||||
end
|
||||
|
||||
def is_finished?(dmsf_file_revision_id)
|
||||
self.dmsf_workflow_step_assignments.each do |assignment|
|
||||
dmsf_workflow_step_assignments.each do |assignment|
|
||||
if assignment.dmsf_file_revision_id == dmsf_file_revision_id
|
||||
if assignment.dmsf_workflow_step_actions.empty?
|
||||
return false
|
||||
@ -61,9 +64,10 @@ class DmsfWorkflowStep < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def copy_to(workflow)
|
||||
new_step = self.dup
|
||||
new_step = dup
|
||||
new_step.dmsf_workflow_id = workflow.id
|
||||
new_step.save
|
||||
return new_step
|
||||
new_step.save!
|
||||
new_step
|
||||
end
|
||||
|
||||
end
|
||||
@ -23,10 +23,12 @@ class DmsfWorkflowStepAction < ActiveRecord::Base
|
||||
belongs_to :dmsf_workflow_step_assignment
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
|
||||
validates_presence_of :dmsf_workflow_step_assignment, :action, :author_id
|
||||
validates_presence_of :note, :unless => lambda { self.action == DmsfWorkflowStepAction::ACTION_APPROVE }
|
||||
validates_uniqueness_of :dmsf_workflow_step_assignment_id, :scope => [:action],
|
||||
:unless => lambda {self.action == DmsfWorkflowStepAction::ACTION_DELEGATE}
|
||||
validates :dmsf_workflow_step_assignment, presence: true
|
||||
validates :action, presence: true
|
||||
validates :author_id, presence: true
|
||||
validates :note, presence: true, :unless => lambda { action == DmsfWorkflowStepAction::ACTION_APPROVE }
|
||||
validates_uniqueness_of :dmsf_workflow_step_assignment_id, scope: [:action],
|
||||
unless: lambda { action == DmsfWorkflowStepAction::ACTION_DELEGATE }
|
||||
|
||||
ACTION_APPROVE = 1
|
||||
ACTION_REJECT = 2
|
||||
@ -45,7 +47,7 @@ class DmsfWorkflowStepAction < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def is_finished?
|
||||
DmsfWorkflowStepAction.is_finished? self.action
|
||||
DmsfWorkflowStepAction.is_finished? action
|
||||
end
|
||||
|
||||
def self.action_str(action)
|
||||
|
||||
@ -25,13 +25,14 @@ class DmsfWorkflowStepAssignment < ActiveRecord::Base
|
||||
|
||||
has_many :dmsf_workflow_step_actions, :dependent => :destroy
|
||||
|
||||
validates_presence_of :dmsf_workflow_step, :dmsf_file_revision
|
||||
validates_uniqueness_of :dmsf_workflow_step_id, :scope => [:dmsf_file_revision_id]
|
||||
validates :dmsf_workflow_step, presence: true
|
||||
validates :dmsf_file_revision, presence: true
|
||||
validates_uniqueness_of :dmsf_workflow_step_id, scope: [:dmsf_file_revision_id]
|
||||
|
||||
def add?(dmsf_file_revision_id)
|
||||
if self.dmsf_file_revision_id == dmsf_file_revision_id
|
||||
if dmsf_file_revision_id == dmsf_file_revision_id
|
||||
add = true
|
||||
self.dmsf_workflow_step_actions.each do |action|
|
||||
dmsf_workflow_step_actions.each do |action|
|
||||
if action.is_finished?
|
||||
add = false
|
||||
break
|
||||
|
||||
30
app/validators/dmsf_file_name_validator.rb
Normal file
30
app/validators/dmsf_file_name_validator.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class DmsfFileNameValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
unless value =~ /\A[^#{DmsfFolder::INVALID_CHARACTERS}]*\z/
|
||||
record.errors.add attribute, :error_contains_invalid_character
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
38
app/validators/dmsf_url_validator.rb
Normal file
38
app/validators/dmsf_url_validator.rb
Normal file
@ -0,0 +1,38 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class DmsfUrlValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
if record.target_type == 'DmsfUrl'
|
||||
begin
|
||||
if value.present?
|
||||
URI.parse value
|
||||
else
|
||||
record.errors.add attribute, :invalid
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
record.errors.add attribute, :invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
49
app/validators/dmsf_workflow_name_validator.rb
Normal file
49
app/validators/dmsf_workflow_name_validator.rb
Normal file
@ -0,0 +1,49 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class DmsfWorkflowNameValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
if record.project_id
|
||||
if record.id
|
||||
if DmsfWorkflow.where(['(project_id IS NULL OR (project_id = ? AND id != ?)) AND name = ?',
|
||||
record.project_id, record.id, value]).exists?
|
||||
record.errors.add attribute, :taken
|
||||
end
|
||||
else
|
||||
if DmsfWorkflow.where(['(project_id IS NULL OR project_id = ?) AND name = ?', record.project_id, value]).exists?
|
||||
record.errors.add attribute, :taken
|
||||
end
|
||||
end
|
||||
else
|
||||
if record.id
|
||||
if DmsfWorkflow.where(['name = ? AND id != ?', value, record.id]).exists?
|
||||
record.errors.add attribute, :taken
|
||||
end
|
||||
else
|
||||
if DmsfWorkflow.where(name: value).exists?
|
||||
record.errors.add attribute, :taken
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -25,7 +25,7 @@
|
||||
<% if object %>
|
||||
<div>
|
||||
<% object.custom_field_values.each do |custom_value| %>
|
||||
<% if !custom_value.value.blank? %>
|
||||
<% unless custom_value.value.blank? %>
|
||||
<div class="status attribute">
|
||||
<%= content_tag :div, h(custom_value.custom_field.name), :class => 'label' %>
|
||||
<div class="value">
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
%>
|
||||
|
||||
<td class="dmsf_checkbox">
|
||||
<% unless (subfolder && subfolder.system) %>
|
||||
<% unless subfolder && subfolder.system %>
|
||||
<%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "subfolder_#{id}") %>
|
||||
<% end %>
|
||||
</td>
|
||||
@ -55,7 +55,7 @@
|
||||
</td>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('extension') %>
|
||||
<td class="dmsf_extension"></td>
|
||||
<td class="dmsf_extension"></td>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('size') %>
|
||||
<td class="dmsf_size"></td>
|
||||
@ -72,8 +72,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(subfolder.user) if subfolder %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf">
|
||||
<%= subfolder.custom_value(c) if subfolder %>
|
||||
|
||||
@ -56,8 +56,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(subfolder.user) if subfolder %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf">
|
||||
<%= subfolder.custom_value(c) if subfolder %>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) if file.last_revision.dmsf_workflow_id %>
|
||||
<% wf = DmsfWorkflow.find_by(id: file.last_revision.dmsf_workflow_id) if file.last_revision.dmsf_workflow_id %>
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "file_#{id}") %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
@ -76,8 +76,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(file.last_revision.user) %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf">
|
||||
<%= file.custom_value(c) %>
|
||||
@ -100,7 +99,7 @@
|
||||
<% else %>
|
||||
<span class="icon-only icon-unlock" title="<%= file.get_locked_title %>"></span>
|
||||
<% end %>
|
||||
<% unless file.locked? %>
|
||||
<% if !file.locked? %>
|
||||
<% if file.notification %>
|
||||
<%= link_to('', notify_deactivate_dmsf_files_path(:id => file),
|
||||
:title => l(:title_notifications_active_deactivate),
|
||||
|
||||
@ -56,8 +56,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(file.last_revision.user) %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf">
|
||||
<%= file.custom_value(c) %>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="dmsf_checkbox dmsf_th">
|
||||
<% if !@system_folder %>
|
||||
<% unless @system_folder %>
|
||||
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
|
||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||||
<% end %>
|
||||
@ -53,8 +53,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<th class="dmsf_th"><%= l(:link_author) %></th>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<th class="dmsf_th"><%= h(c.name) %></th>
|
||||
<% end %>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="dmsf_checkbox dmsf_th">
|
||||
<% if !@system_folder %>
|
||||
<% unless @system_folder %>
|
||||
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
|
||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||||
<% end %>
|
||||
@ -53,8 +53,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<th class ="dmsf_th"><%= l(:link_author) %></th>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<th class="dmsf_th"><%= c.name %></th>
|
||||
<% end %>
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
</td>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('extension') %>
|
||||
<td class="dmsf_extension"></td>
|
||||
<td class="dmsf_extension"></td>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('size') %>
|
||||
<td class="dmsf_size"></td>
|
||||
@ -57,8 +57,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(link.user) %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf"></td>
|
||||
<% end %>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false) %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<td class="id"></td>
|
||||
<td class="id"></td>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('title') %>
|
||||
<td class="dmsf_title">
|
||||
@ -51,8 +51,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<td class="dmsf_author"><%= h(link.user) %></td>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<td class="dmsf_cf"></td>
|
||||
<% end %>
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'dmsf/add_email') %>");
|
||||
var modal = $('#ajax-modal');
|
||||
|
||||
modal.html("<%= escape_javascript(render :partial => 'dmsf/add_email') %>");
|
||||
showModal('ajax-modal', '400px');
|
||||
$('#ajax-modal').addClass('new-user');
|
||||
modal.addClass('new-user');
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
// Store DMSF controls
|
||||
var dmsfButtons = $('#dmsf_buttons')[0].outerHTML;
|
||||
var browserInfo = $('#browser_info').text();
|
||||
var tag = $('#dmsf_tag');
|
||||
var dmsfTag;
|
||||
var browser = $("#browser");
|
||||
|
||||
if(($('#dmsf_tag') != null) && $('#dmsf_tag')[0] != null) {
|
||||
if((tag != null) && tag[0] != null) {
|
||||
|
||||
dmsfTag = $('#dmsf_tag')[0].outerHTML
|
||||
dmsfTag = tag[0].outerHTML
|
||||
}
|
||||
|
||||
// Destroy the original dataTable
|
||||
$("#browser").dataTable().fnDestroy();
|
||||
browser.dataTable().fnDestroy();
|
||||
|
||||
// Add rows
|
||||
$('#<%= params[:row_id] %>').after('<%= escape_javascript(render(:partial => 'dmsf/dmsf_rows')) %>');
|
||||
@ -27,7 +29,7 @@ hideOnLoad();
|
||||
<% size = DmsfFolder.get_column_position('size') %>
|
||||
<% modified = DmsfFolder.get_column_position('modified') %>
|
||||
|
||||
$('#browser').dataTable({
|
||||
browser.dataTable({
|
||||
orderClasses: false,
|
||||
responsive: {
|
||||
details: false
|
||||
@ -55,10 +57,11 @@ $('#browser').dataTable({
|
||||
<% end %>
|
||||
],
|
||||
"fnInitComplete": function() {
|
||||
$(dmsfButtons).prependTo($("#browser_wrapper div.fg-toolbar")[0]);
|
||||
if($(dmsfTag) != null) {
|
||||
$(dmsfTag).prependTo($("#browser_wrapper div.fg-toolbar")[0]);
|
||||
}
|
||||
var wrapper = $("#browser_wrapper div.fg-toolbar")[0];
|
||||
$(dmsfButtons).prependTo(wrapper);
|
||||
if($(dmsfTag) != null) {
|
||||
$(dmsfTag).prependTo(wrapper);
|
||||
}
|
||||
},
|
||||
"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
|
||||
return browserInfo;
|
||||
@ -66,4 +69,4 @@ $('#browser').dataTable({
|
||||
});
|
||||
|
||||
// Hot fix
|
||||
$('#browser').attr('style', 'width: 100%');
|
||||
browser.attr('style', 'width: 100%');
|
||||
|
||||
@ -26,13 +26,13 @@
|
||||
|
||||
<div class="contextual">
|
||||
<% if !@folder.new_record? && User.current.allowed_to?(:folder_manipulation, @project) && !@folder.system %>
|
||||
<% unless @folder.locked? %>
|
||||
<%= link_to(l(:button_lock), lock_dmsf_path(:id => @project, :folder_id => @folder),
|
||||
:title => l(:title_lock_file), :class => 'icon icon-lock') %>
|
||||
<% else %>
|
||||
<% if @folder.locked? %>
|
||||
<%= link_to_if(@folder.unlockable? && (!@folder.locked_for_user? || @force_file_unlock_allowed), l(:button_unlock),
|
||||
unlock_dmsf_path(:id => @project, :folder_id => @folder),
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock')%>
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock') %>
|
||||
<% else %>
|
||||
<%= link_to(l(:button_lock), lock_dmsf_path(:id => @project, :folder_id => @folder),
|
||||
:title => l(:title_lock_file), :class => 'icon icon-lock') %>
|
||||
<% end %>
|
||||
<% unless @folder.locked? %>
|
||||
<% if @folder.notification %>
|
||||
@ -77,7 +77,7 @@
|
||||
<p>
|
||||
<%= label_tag '', l(:label_permissions) %>
|
||||
<% User.current.managed_roles(@project).each do |role| %>
|
||||
<% checked = @folder.dmsf_folder_permissions.roles.exists?(:object_id => role.id) %>
|
||||
<% checked = @folder.dmsf_folder_permissions.roles.exists?(object_id: role.id) %>
|
||||
<label class="inline"><%= check_box_tag 'permissions[role_ids][]', role.id, checked, :id => nil %> <%= role %></label>
|
||||
<% end %>
|
||||
<span id="user_permissions">
|
||||
@ -95,7 +95,7 @@
|
||||
:method => 'get' %>
|
||||
</span>
|
||||
</p>
|
||||
<% values = @folder ? @folder.custom_field_values : @parent ? @parent.custom_field_values : DmsfFolder.new.custom_field_values %>
|
||||
<% values = @folder ? @folder.custom_field_values : (@parent ? @parent.custom_field_values : DmsfFolder.new.custom_field_values) %>
|
||||
<% values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label(:dmsf_folder, value) %></p>
|
||||
<% end %>
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
|
||||
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
|
||||
<%= hidden_field_tag('action') %>
|
||||
<% if !@system_folder %>
|
||||
<% unless @system_folder %>
|
||||
<div id="dmsf_buttons" class="dmsf_controls" style="float: left">
|
||||
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries',
|
||||
:class => 'toggle-selection') if @file_view_allowed %>
|
||||
@ -183,7 +183,7 @@
|
||||
<% if @folder %>
|
||||
return "<%= "#{l(:label_number_of_folders)}: #{@folder.deep_folder_count} #{l(:label_number_of_documents)}: #{@folder.deep_file_count}" %>";
|
||||
<% else %>
|
||||
return "<%= "#{l(:label_number_of_folders)}: #{DmsfFolder.visible.where(:project_id => @project.id).count + DmsfLink.visible.where(:project_id => @project.id, :target_type => 'DmsfFolder').count}, #{l(:label_number_of_documents)}: #{DmsfFile.visible.where(:project_id => @project.id).count + DmsfLink.visible.where(:project_id => @project.id, :target_type => ['DmsfFile', 'DmsfUrl']).count}" %>";
|
||||
return "<%= "#{l(:label_number_of_folders)}: #{DmsfFolder.visible.where(:project_id => @project.id).count + DmsfLink.visible.where(:project_id => @project.id, :target_type => 'DmsfFolder').count}, #{l(:label_number_of_documents)}: #{DmsfFile.visible.where(:project_id => @project.id).count + DmsfLink.visible.where(:project_id => @project.id, :target_type => %w(DmsfFile DmsfUrl)).count}" %>";
|
||||
<% end %>
|
||||
<% else %>
|
||||
return "<%= "#{l(:label_number_of_folders)}: #{@subfolders.count + @dir_links.count}, #{l(:label_number_of_documents)}: #{@files.count + @file_links.count + @url_links.count}" %>";
|
||||
@ -215,7 +215,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if (@file_manipulation_allowed && !@locked_for_user && !@system_folder) %>
|
||||
<% if @file_manipulation_allowed && !@locked_for_user && !@system_folder %>
|
||||
<%= render(:partial => 'dmsf_upload/multi_upload', :local => { :lbl => true }) %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -76,8 +76,7 @@
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<th class="dmsf_th"><%= l(:link_author) %></th>
|
||||
<% end %>
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% cfs.each do |c| %>
|
||||
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<th class="dmsf_th"><%= h(c.name) %></th>
|
||||
<% end %>
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<% else %>
|
||||
<span class="icon-only icon-unlock" title="<%= dmsf_file.get_locked_title %>"></span>
|
||||
<% end %>
|
||||
<% unless dmsf_file.locked? %>
|
||||
<% if !dmsf_file.locked? %>
|
||||
<% # Notifications %>
|
||||
<% if dmsf_file.notification %>
|
||||
<%= link_to('', notify_deactivate_dmsf_files_path(:id => dmsf_file),
|
||||
@ -91,7 +91,7 @@
|
||||
<span class="icon-only"></span>
|
||||
<% end %>
|
||||
<% # Approval workflow %>
|
||||
<% wf = DmsfWorkflow.find_by_id(dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>
|
||||
<% wf = DmsfWorkflow.find_by(id: dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>
|
||||
<%= render(:partial => 'dmsf_workflows/approval_workflow_button',
|
||||
:locals => {:file => dmsf_file,
|
||||
:file_approval_allowed => User.current.allowed_to?(:file_approval, dmsf_file.project),
|
||||
|
||||
@ -26,37 +26,37 @@
|
||||
|
||||
<div class="contextual">
|
||||
<% if @file_manipulation_allowed %>
|
||||
<% unless @file.locked_for_user? %>
|
||||
<% unless @file.locked? %>
|
||||
<%= link_to(l(:button_lock), lock_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_lock_file), :class => 'icon icon-lock') %>
|
||||
<% else %>
|
||||
<% if @file.locked_for_user? %>
|
||||
<% if User.current.allowed_to?(:force_file_unlock, @project) %>
|
||||
<%= link_to_if(@file.unlockable?, l(:button_unlock), unlock_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock') %>
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock')%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @file.locked? %>
|
||||
<%= link_to_if(@file.unlockable?, l(:button_unlock), unlock_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock') %>
|
||||
<% else %>
|
||||
<%= link_to(l(:button_lock), lock_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_lock_file), :class => 'icon icon-lock') %>
|
||||
<% end %>
|
||||
<% if @file.notification %>
|
||||
<%= link_to(l(:label_notifications_off),
|
||||
notify_deactivate_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_notifications_active_deactivate),
|
||||
:class => 'icon icon-email') %>
|
||||
notify_deactivate_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_notifications_active_deactivate),
|
||||
:class => 'icon icon-email') %>
|
||||
<% else %>
|
||||
<%= link_to(l(:label_notifications_on),
|
||||
notify_activate_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_notifications_not_active_activate),
|
||||
:class => 'icon icon-email-add') %>
|
||||
notify_activate_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_notifications_not_active_activate),
|
||||
:class => 'icon icon-email-add') %>
|
||||
<% end %>
|
||||
<%= link_to(l(:label_link_to),
|
||||
new_dmsf_link_path(:project_id => @project.id, :dmsf_folder_id => @file.dmsf_folder ? @file.dmsf_folder.id : nil, :dmsf_file_id => @file.id, :type => 'link_to'),
|
||||
:title => l(:title_create_link),
|
||||
:class => 'icon icon-link') %>
|
||||
new_dmsf_link_path(:project_id => @project.id, :dmsf_folder_id => @file.dmsf_folder ? @file.dmsf_folder.id : nil, :dmsf_file_id => @file.id, :type => 'link_to'),
|
||||
:title => l(:title_create_link),
|
||||
:class => 'icon icon-link') %>
|
||||
<%= link_to("#{l(:button_copy)}/#{l(:button_move)}", copy_file_path(:id => @file),
|
||||
:title => l(:title_copy), :class => 'icon icon-copy') %>
|
||||
:title => l(:title_copy), :class => 'icon icon-copy') %>
|
||||
<%= delete_link(dmsf_file_path(:id => @file, :details => true)) if @file_delete_allowed %>
|
||||
<% else %>
|
||||
<% if User.current.allowed_to?(:force_file_unlock, @project) %>
|
||||
<%= link_to_if(@file.unlockable?, l(:button_unlock), unlock_dmsf_files_path(:id => @file),
|
||||
:title => l(:title_unlock_file), :class => 'icon icon-unlock')%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -127,7 +127,7 @@
|
||||
<%= content_tag :div, l(:label_size), :class => 'label' %>
|
||||
<%= content_tag :div, number_to_human_size(revision.size), :class => 'value' %>
|
||||
</div>
|
||||
<% wf = DmsfWorkflow.find_by_id(revision.dmsf_workflow_id) %>
|
||||
<% wf = DmsfWorkflow.find_by(id: revision.dmsf_workflow_id) %>
|
||||
<% if wf %>
|
||||
<div class="status attribute">
|
||||
<%= content_tag :div, l(:label_workflow), :class => 'label' %>
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
var modal = $('#ajax-modal');
|
||||
|
||||
$('#users_for_watcher').html('<%= escape_javascript(render_principals_for_new_folder_permissions(@principals)) %>');
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'dmsf_folder_permissions/new') %>');
|
||||
modal.html('<%= escape_javascript(render :partial => 'dmsf_folder_permissions/new') %>');
|
||||
showModal('ajax-modal', '400px');
|
||||
$('#ajax-modal').addClass('new-user');
|
||||
modal.addClass('new-user');
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
%>
|
||||
|
||||
<% if projects.present? %>
|
||||
<%= form_tag({:action => 'copy', :id => file_or_folder}, :id => 'copyForm') do |f| %>
|
||||
<%= form_tag({:action => 'copy', :id => file_or_folder}, :id => 'copyForm') do %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<%= label_tag('target_project_id', l(:field_target_project)) %>
|
||||
|
||||
@ -1,4 +1,28 @@
|
||||
$('#dmsf_link_target_folder_id').html('<%= escape_javascript(
|
||||
<%
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
var link = $('#dmsf_link_target_folder_id');
|
||||
|
||||
link.html('<%= escape_javascript(
|
||||
select_tag('dmsf_link[target_folder_id]',
|
||||
folder_tree_options_for_select(DmsfFolder.directory_tree(params[:dmsf_link][:target_project_id])))) %>');
|
||||
$('#dmsf_link_target_folder_id').change();
|
||||
link.change();
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
<% files = [] %>
|
||||
<% if @folders.present? %>
|
||||
<% JSON.parse(@folders).each do |id| %>
|
||||
<% folder = DmsfFolder.find_by_id id %>
|
||||
<% folder = DmsfFolder.find_by(id: id) %>
|
||||
<% if folder %>
|
||||
<% folder.folder_tree.each do |name, i| %>
|
||||
<% dir = DmsfFolder.find_by_id i %>
|
||||
<% dir = DmsfFolder.find_by(id: i) %>
|
||||
<% if dir && !folders.include?(dir) %>
|
||||
<br/>
|
||||
<%= link_to(h(dir.dmsf_path_str), dmsf_folder_path(:id => dir.project_id, :folder_id => dir.id, :only_path => false)) %>
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
<% files = [] %>
|
||||
<% if @folders.present? %>
|
||||
<% JSON.parse(@folders).each do |id| %>
|
||||
<% folder = DmsfFolder.find_by_id id %>
|
||||
<% folder = DmsfFolder.find_by(id: id) %>
|
||||
<% if folder && !folders.include?(folder) %>
|
||||
<% folder.folder_tree.each do |name, i| %>
|
||||
<% dir = DmsfFolder.find_by_id i %>
|
||||
<% dir = DmsfFolder.find_by(id: i) %>
|
||||
<% if dir %>
|
||||
<%= dir.dmsf_path_str %>
|
||||
<% dir.dmsf_files.each do |file| %>
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
</p>
|
||||
<p>
|
||||
<%= @text2 %>
|
||||
<% unless @revision.dmsf_file.dmsf_folder %>
|
||||
<%= link_to l(:link_documents),
|
||||
dmsf_folder_url(:id => @revision.dmsf_file.project) %>
|
||||
<% else %>
|
||||
<%= link_to @revision.dmsf_file.dmsf_folder.title,
|
||||
<% if @revision.dmsf_file.dmsf_folder %>
|
||||
<%= link_to @revision.dmsf_file.dmsf_folder.title,
|
||||
dmsf_folder_url(:id => @revision.dmsf_file.project, :folder_id => @revision.dmsf_file.dmsf_folder) %>
|
||||
<% else %>
|
||||
<%= link_to l(:link_documents),
|
||||
dmsf_folder_url(:id => @revision.dmsf_file.project) %>
|
||||
<% end %>.
|
||||
</p>
|
||||
@ -21,8 +21,8 @@
|
||||
|
||||
<%= @user.name %>,
|
||||
<%= @text1 %>
|
||||
<% unless @revision.dmsf_file.dmsf_folder %>
|
||||
<%= @text2 %> <%= dmsf_folder_url(:id => @revision.dmsf_file.project) %>.
|
||||
<% if @revision.dmsf_file.dmsf_folder %>
|
||||
<%= @text2 %> <%= dmsf_folder_url(:id => @revision.dmsf_file.project, :folder_id => @revision.dmsf_file.dmsf_folder) %>.
|
||||
<% else %>
|
||||
<%= @text2 %> <%= dmsf_folder_url(:id => @revision.dmsf_file.project, :folder_id => @revision.dmsf_file.dmsf_folder) %>.
|
||||
<%= @text2 %> <%= dmsf_folder_url(:id => @revision.dmsf_file.project) %>.
|
||||
<% end %>
|
||||
@ -18,7 +18,7 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%>
|
||||
|
||||
<% member = Member.find_by_project_id_and_user_id(@project.id, User.current.id) %>
|
||||
<% member = Member.find_by(project_id: @project.id, user_id: User.current.id) %>
|
||||
<% if member %>
|
||||
<% mail_notification = member.dmsf_mail_notification %>
|
||||
<% title_format = member.dmsf_title_format %>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<span id="dmsf_attachments_fields">
|
||||
<% if defined?(container) && container && container.saved_dmsf_attachments.present? %>
|
||||
<% container.saved_dmsf_attachments.each_with_index do |attachment, i| %>
|
||||
<span id="dmsf_attachments_p<%= i %>", class="attachment">
|
||||
<span id="dmsf_attachments_p<%= i %>" class="attachment">
|
||||
<%= hidden_field_tag "dmsf_attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
<%= text_field_tag("dmsf_attachments[p#{i}][filename]", attachment.filename, :class => 'filename') %>
|
||||
<%= text_field_tag("dmsf_attachments[p#{i}][description]", attachment.description, :maxlength => 255,
|
||||
@ -32,7 +32,7 @@
|
||||
:method => 'delete', :remote => true, :class => 'remove-upload icon-only icon-del') %>
|
||||
<% wf = container.saved_dmsf_attachments_wfs[attachment.id] %>
|
||||
<% if wf %>
|
||||
<a href="javascript:void(0);" title="<%= l(:title_assigned) %>" class="icon-only icon-wf-assigned"></a>
|
||||
<a href="javascript:void(0);" title="<%= l(:title_assigned) %>" class="icon-only icon-wf-assigned"></a>
|
||||
<%= hidden_field_tag("dmsf_attachments_wfs[p#{i}]", wf.id) if wf %>
|
||||
<% else %>
|
||||
<%= link_to('', assign_dmsf_workflow_path(:id => container.project.id, :project_id => container.project.id,
|
||||
@ -47,14 +47,14 @@
|
||||
<span id="dmsf_links_attachments_fields">
|
||||
<% if defined?(container) && container && container.saved_dmsf_links.present? %>
|
||||
<% container.saved_dmsf_links.each_with_index do |dmsf_link, index| %>
|
||||
<span id="dmsf_links_attachments_<%= index %>", class="attachment">
|
||||
<span id="dmsf_links_attachments_<%= index %>" class="attachment">
|
||||
<input name="dmsf_links[<%= index %>]" value="<%= dmsf_link.id %>" type="hidden">
|
||||
<input type="text" class='filename readonly' value="<%= dmsf_link.name %>">
|
||||
<%= link_to('', dmsf_link_attachment_path(dmsf_link, :link_id => "#{index}", :format => 'js'),
|
||||
:method => 'delete', :remote => true, :class => 'remove-upload icon-only icon-del') %>
|
||||
<% wf = container.saved_dmsf_links_wfs[dmsf_link.id] %>
|
||||
<% if wf %>
|
||||
<a href="javascript:void(0);" title="<%= l(:title_assigned) %>" class="modify-upload icon-only icon-wf-assigned"></a>
|
||||
<a href="javascript:void(0);" title="<%= l(:title_assigned) %>" class="modify-upload icon-only icon-wf-assigned"></a>
|
||||
<%= hidden_field_tag("dmsf_links_wfs[#{dmsf_link.id}]", wf.id) if wf %>
|
||||
<% else %>
|
||||
<%= render(:partial => 'dmsf_workflows/approval_workflow_button',
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<%= text_area_tag :note, '', :placeholder => l(:message_dmsf_wokflow_note), :style => 'width: 90%' %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<div>
|
||||
<%= label_tag 'delegate', l(:label_dmsf_wokflow_action_delegate) %><br/>
|
||||
<%= text_field_tag 'user_search', nil %>
|
||||
<%= late_javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, :dmsf_workflow_step_assignment_id => params[:dmsf_workflow_step_assignment_id], :dmsf_file_revision_id => params[:dmsf_file_revision_id]) }')" %>
|
||||
@ -49,7 +49,7 @@
|
||||
<%= render_principals_for_new_dmsf_workflow_users(
|
||||
@dmsf_workflow, params[:dmsf_workflow_step_assignment_id], params[:dmsf_file_revision_id]) %>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_submit), :name => 'commit', :onclick => 'hideModal(this);' %>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<% if wf %>
|
||||
<% assignments = wf.next_assignments(file.last_revision.id) %>
|
||||
<% index = assignments.find_index{|assignment| assignment.user_id == User.current.id} if assignments %>
|
||||
<% if index %>
|
||||
<% if assignments && index %>
|
||||
<%= link_to('',
|
||||
action_dmsf_workflow_path(
|
||||
:project_id => project.id,
|
||||
@ -37,7 +37,7 @@
|
||||
:remote => true,
|
||||
:class => "icon-only icon-wf-waiting") %>
|
||||
<% else %>
|
||||
<span class="icon-only"></span>
|
||||
<span class="icon-only"></span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="icon-only"></span>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<h3 class="title"><%= l(:title_dmsf_workflow_log) %></h3>
|
||||
<p>
|
||||
<% if params[:dmsf_file_revision_id].present? %>
|
||||
<% revision = DmsfFileRevision.find_by_id(params[:dmsf_file_revision_id]) %>
|
||||
<% revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id]) %>
|
||||
<% if revision %>
|
||||
<div class="dmsf_log_header_box">
|
||||
<div class="dmsf_log_header_left">
|
||||
@ -44,7 +44,7 @@
|
||||
<thead><tr>
|
||||
<th></th>
|
||||
<th><%= l(:label_dmsf_workflow_step) %></th>
|
||||
<th><%= l(:label_user) %> </th>
|
||||
<th><%= l(:label_user) %></th>
|
||||
<th><%= l(:label_action) %></th>
|
||||
<th><%= l(:link_workflow) %></th>
|
||||
<th><%= l(:label_note) %></th>
|
||||
@ -52,18 +52,18 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr id="step-0" class="even">
|
||||
<td class="id"/>
|
||||
<td/>
|
||||
<td/>
|
||||
<td/>
|
||||
<td class="id"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><%= DmsfWorkflowStepAction.workflow_str(0) %></td>
|
||||
<td class="dmsf_note"></td>
|
||||
<td/>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr id="step-1" class="odd">
|
||||
<td class="id"></td>
|
||||
<td/>
|
||||
<td><%= link_to_user User.find_by_id(revision.dmsf_workflow_assigned_by) if revision.dmsf_workflow_assigned_by %></td>
|
||||
<td></td>
|
||||
<td><%= link_to_user User.find_by(id: revision.dmsf_workflow_assigned_by) if revision.dmsf_workflow_assigned_by %></td>
|
||||
<td><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %></td>
|
||||
<td><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %></td>
|
||||
<td class="dmsf_note"></td>
|
||||
@ -71,8 +71,8 @@
|
||||
</tr>
|
||||
<tr id="step-2" class="even">
|
||||
<td class="id"></td>
|
||||
<td/>
|
||||
<td><%= link_to_user User.find_by_id(revision.dmsf_workflow_started_by) if revision.dmsf_workflow_started_by %></td>
|
||||
<td></td>
|
||||
<td><%= link_to_user User.find_by(id: revision.dmsf_workflow_started_by) if revision.dmsf_workflow_started_by %></td>
|
||||
<td><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_START) %></td>
|
||||
<td><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by %></td>
|
||||
<td class="dmsf_note"></td>
|
||||
@ -86,10 +86,10 @@
|
||||
<td class="id"><%= row['step'] unless row['step'] == last_step %></td>
|
||||
<% last_step = row['step'] %>
|
||||
<td class="name"><%= row['name'] %></td>
|
||||
<td><%= link_to_user User.find_by_id(row['author_id'].present? ? row['author_id'] : row['user_id']) %></td>
|
||||
<td><%= link_to_user User.find_by(id: row['author_id'].present? ? row['author_id'] : row['user_id']) %></td>
|
||||
<td><%= DmsfWorkflowStepAction.action_str(row['action']) %></td>
|
||||
<td>
|
||||
<% if((row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE)) %>
|
||||
<% if (row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE) %>
|
||||
<%= l(:title_approved) %>
|
||||
<% else %>
|
||||
<%= DmsfWorkflowStepAction.workflow_str(row['action']) %>
|
||||
|
||||
@ -43,10 +43,10 @@
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th><%=l(:field_name)%></th>
|
||||
<th></th>
|
||||
<th/>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for workflow in @workflows %>
|
||||
<% @workflows.each do |workflow| %>
|
||||
<tr id="workflow-<%= workflow.id %>" class="dmsf_workflows <%= workflow.active? ? 'active' : 'locked' %>">
|
||||
<td class="name"><%= link_to(h(workflow.name), dmsf_workflow_path(workflow)) %></td>
|
||||
<td class="buttons">
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
<th></th>
|
||||
<th><%= l(:label_dmsf_workflow_step) %></th>
|
||||
<th><%= l(:label_dmsf_workflow_approval_plural) %></th>
|
||||
<th></th>
|
||||
<th>/th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% steps.each do |i|%>
|
||||
@ -74,9 +74,9 @@
|
||||
<%= link_to_user step.user %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div id="<%= "step-index-#{index}-approvers-form" %>", class="hol">
|
||||
<div id="<%= "step-index-#{index}-approvers-form" %>" class="hol">
|
||||
<div class="dmsf_parent_container">
|
||||
<% stps.each_with_index do |step, j| %>
|
||||
<% stps.each do |step| %>
|
||||
<div class="dmsf_child_container">
|
||||
<label>
|
||||
<%= radio_button_tag "operator_step[#{step.id}]", DmsfWorkflowStep::OPERATOR_AND,
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'action', :locals => {:workflow => @dmsf_workflow}) %>');
|
||||
var modal = $('#ajax-modal');
|
||||
|
||||
modal.html('<%= escape_javascript(render :partial => 'action', :locals => {:workflow => @dmsf_workflow}) %>');
|
||||
showModal('ajax-modal', '35%');
|
||||
$('#ajax-modal').addClass('new-action');
|
||||
modal.addClass('new-action');
|
||||
@ -20,6 +20,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'assign') %>');
|
||||
var modal = $('#ajax-modal');
|
||||
|
||||
modal.html('<%= escape_javascript(render :partial => 'assign') %>');
|
||||
showModal('ajax-modal', '30%');
|
||||
$('#ajax-modal').addClass('assignment');
|
||||
modal.addClass('assignment');
|
||||
@ -19,6 +19,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%>
|
||||
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'log', :locals => {:workflow => @dmsf_workflow}) %>');
|
||||
var modal = $('#ajax-modal');
|
||||
|
||||
modal.html('<%= escape_javascript(render :partial => 'log', :locals => {:workflow => @dmsf_workflow}) %>');
|
||||
showModal('ajax-modal', '90%');
|
||||
$('#ajax-modal').addClass('workflow-log');
|
||||
modal.addClass('workflow-log');
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
|
||||
<% dmsf_file_or_folder = object %>
|
||||
<% if dmsf_file_or_folder.dmsf_folder_id %>
|
||||
<% dmsf_folder = DmsfFolder.find_by_id dmsf_file_or_folder.dmsf_folder_id %>
|
||||
<% title = dmsf_folder.title if dmsf_folder %>
|
||||
<% titles = DmsfFolder.where(id: dmsf_file_or_folder.dmsf_folder_id).pluck(:title) %>
|
||||
<% title = titles.first %>
|
||||
<% else %>
|
||||
<% title = dmsf_file_or_folder.project.name %>
|
||||
<% end %>
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
|
||||
<% columns.concat(cfs.map{ |c| c.name }) %>
|
||||
<% selected_columns = DmsfFolder::DEFAULT_COLUMNS if selected_columns.blank? %>
|
||||
<% columns.each_with_index do |column, i| %>
|
||||
<% columns.each do |column| %>
|
||||
<%= check_box_tag('settings[dmsf_columns][]', column, selected_columns.include?(column)) %>
|
||||
<%= h column.capitalize %>
|
||||
<br/>
|
||||
|
||||
@ -79,8 +79,7 @@
|
||||
<% testfilename = DmsfFile.storage_path.join('test.test') %>
|
||||
<% if File.exist?(storage_dir) %>
|
||||
<% begin %>
|
||||
<% File.open(testfilename, 'wb') do |file| %>
|
||||
<% end %>
|
||||
<% File.open(testfilename, 'wb') %>
|
||||
<% rescue %>
|
||||
<p class="warning"><%= l(:error_file_can_not_be_created) %></p>
|
||||
<% ensure %>
|
||||
@ -110,8 +109,7 @@
|
||||
<% testfilename = path.join('test.test') %>
|
||||
<% if File.exist?(tmpdir) %>
|
||||
<% begin %>
|
||||
<% File.open(testfilename, 'wb') do |file| %>
|
||||
<% end %>
|
||||
<% File.open(testfilename, 'wb') %>
|
||||
<% rescue %>
|
||||
<p class="warning"><%= l(:error_tmpfile_can_not_be_created) %></p>
|
||||
<% ensure %>
|
||||
@ -316,7 +314,7 @@
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_enable_cjk_ngrams)) %>
|
||||
<%= check_box_tag 'settings[enable_cjk_ngrams]', true, @settings['enable_cjk_ngrams'] == 'true' %>
|
||||
<%= check_box_tag 'settings[enable_cjk_ngrams]', true, @settings['dmsf_enable_cjk_ngrams'] %>
|
||||
<em class="info">
|
||||
<%= l(:text_enable_cjk_ngrams) %>
|
||||
</em>
|
||||
|
||||
@ -49,7 +49,9 @@ dmsfAddLink.nextLinkId = 1000;
|
||||
|
||||
function dmsfAddFile(inputEl, file, eagerUpload) {
|
||||
|
||||
if ($('#dmsf_attachments_fields').children().length < 10) {
|
||||
var attachments = $('#dmsf_attachments_fields');
|
||||
|
||||
if (attachments.children().length < 10) {
|
||||
|
||||
var attachmentId = dmsfAddFile.nextAttachmentId++;
|
||||
var fileSpan = $('<span>', { id: 'dmsf_attachments_' + attachmentId, 'class': 'attachment' });
|
||||
@ -82,11 +84,11 @@ function dmsfAddFile(inputEl, file, eagerUpload) {
|
||||
fileSpan.append(iconWf);
|
||||
}
|
||||
|
||||
$('#dmsf_attachments_fields').append(fileSpan);
|
||||
attachments.append(fileSpan);
|
||||
}
|
||||
else{
|
||||
fileSpan.append(fileName);
|
||||
$('#dmsf_attachments_fields').append(fileSpan);
|
||||
attachments.append(fileSpan);
|
||||
$('#dmsf_file_revision_name').val(file.name);
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
"sInfoThousands": " ",
|
||||
"sLoadingRecords": "Lastar...",
|
||||
"sLengthMenu": "Syn _MENU_ linjer",
|
||||
"sLoadingRecords": "Lastar...",
|
||||
"sProcessing": "Lastar...",
|
||||
"sSearch": "Søk:",
|
||||
"sUrl": "",
|
||||
@ -20,7 +19,7 @@
|
||||
"sPrevious": "Forrige",
|
||||
"sNext": "Neste",
|
||||
"sLast": "Siste"
|
||||
}
|
||||
},
|
||||
"oAria": {
|
||||
"sSortAscending": ": aktiver for å sortere kolonna stigande",
|
||||
"sSortDescending": ": aktiver for å sortere kolonna synkande"
|
||||
|
||||
@ -41,7 +41,7 @@ function dmsfToggle(EL, PM, url)
|
||||
dmsfExpandRows(EL, selectedRow, url);
|
||||
}
|
||||
|
||||
for(i = 0; i < elsLen; i++)
|
||||
for(var i = 0; i < elsLen; i++)
|
||||
{
|
||||
if(cpattern.test(els[i].id))
|
||||
{
|
||||
@ -65,7 +65,7 @@ function dmsfToggle(EL, PM, url)
|
||||
|
||||
if(pattern.test(els[i].className))
|
||||
{
|
||||
var cnames = els[i].className;
|
||||
let cnames = els[i].className;
|
||||
|
||||
cnames = cnames.replace(/dmsf_hidden/g,'');
|
||||
|
||||
@ -89,7 +89,7 @@ function dmsfToggle(EL, PM, url)
|
||||
|
||||
if(!(hide.test(els[i].className)))
|
||||
{
|
||||
var cnames = els[i].className;
|
||||
let cnames = els[i].className;
|
||||
|
||||
cnames = cnames.replace(/odd/g,'');
|
||||
cnames = cnames.replace(/even/g,'');
|
||||
@ -110,14 +110,14 @@ function dmsfToggle(EL, PM, url)
|
||||
|
||||
if (collapse.test(selectedRow.className))
|
||||
{
|
||||
var cnames = selectedRow.className;
|
||||
let cnames = selectedRow.className;
|
||||
|
||||
cnames = cnames.replace(/dmsf_collapsed/,'dmsf_expanded');
|
||||
selectedRow.className = cnames;
|
||||
}
|
||||
else
|
||||
{
|
||||
var cnames = selectedRow.className;
|
||||
let cnames = selectedRow.className;
|
||||
|
||||
cnames = cnames.replace(/dmsf_expanded/,'dmsf_collapsed');
|
||||
selectedRow.className = cnames;
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#dmsf_tag .check_box_group {
|
||||
background: inherit;
|
||||
border: 0px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.list .dmsf_modified {
|
||||
@ -68,7 +68,7 @@
|
||||
}
|
||||
|
||||
.list .dmsf_checkbox input {
|
||||
padding:0px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.list .dmsf_checkbox .DataTables_sort_wrapper {
|
||||
@ -152,7 +152,7 @@ table.display thead th div.DataTables_sort_wrapper span {
|
||||
|
||||
/* DMSF revision box */
|
||||
.dmsf_revision_box {
|
||||
padding: 0px 0px 0px 0px;
|
||||
padding: 0 0 0 0;
|
||||
margin-bottom: 10px;
|
||||
background-color:#f6f6f6;
|
||||
color:#505050;
|
||||
@ -201,7 +201,7 @@ div.dmsf_revision_inner_box .attribute .label {
|
||||
|
||||
.dmsf_log_header_box label{
|
||||
font-weight: bold;
|
||||
margin-left: 0px;
|
||||
margin-left: 0;
|
||||
margin-right: 3px;
|
||||
padding: 3px 0 3px 0;
|
||||
}
|
||||
@ -349,13 +349,13 @@ div.dmsf_revision_inner_box .attribute .label {
|
||||
|
||||
#dmsf_attachments_fields input.description {margin-left:4px; width:340px;}
|
||||
#dmsf_attachments_fields span {display:block; white-space:nowrap;}
|
||||
#dmsf_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}
|
||||
#dmsf_attachments_fields .ajax-waiting input.filename {background:url(../../../images/hourglass.png) no-repeat 0px 50%;}
|
||||
#dmsf_attachments_fields .ajax-loading input.filename {background:url(../../../images/loading.gif) no-repeat 0px 50%;}
|
||||
#dmsf_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/attachment.png) no-repeat 1px 50%; padding-left: 18px;}
|
||||
#dmsf_attachments_fields .ajax-waiting input.filename {background:url(../../../images/hourglass.png) no-repeat 0 50%;}
|
||||
#dmsf_attachments_fields .ajax-loading input.filename {background:url(../../../images/loading.gif) no-repeat 0 50%;}
|
||||
#dmsf_attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
|
||||
|
||||
#dmsf_links_attachments_fields span {display:block; white-space:nowrap;}
|
||||
#dmsf_links_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/link.png) no-repeat 1px 50%; padding-left:18px;}
|
||||
#dmsf_links_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/link.png) no-repeat 1px 50%; padding-left: 18px;}
|
||||
|
||||
/* New link form*/
|
||||
#dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id, #dmsf_link_name{
|
||||
|
||||
@ -168,8 +168,6 @@ cs:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Soubor
|
||||
field_folder: Složka
|
||||
error_create_cycle_in_folder_dependency: vytvořit smyčku v závislostech složky
|
||||
error_contains_invalid_character: obsahuje neplatné znaky
|
||||
error_file_commit_require_uploaded_file: Potvrzení vyžaduje nahraný soubor
|
||||
|
||||
warning_some_files_were_not_commited: "Některé soubory nebyly potvrzené z důvodu chyb při validaci: %{files}"
|
||||
@ -418,3 +416,8 @@ cs:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: obsahuje neplatné znaky
|
||||
@ -168,8 +168,6 @@ de:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Datei
|
||||
field_folder: Ordner
|
||||
error_create_cycle_in_folder_dependency: Zirkelabhängigkeit in der Ordnerstruktur erstellt
|
||||
error_contains_invalid_character: enthält ungültige Zeichen
|
||||
error_file_commit_require_uploaded_file: Der Commit erfordet eine hochladene Datei
|
||||
|
||||
warning_some_files_were_not_commited: "Einige Dateien wurden wegen Validierungsfehlern nicht commitet: %{files}"
|
||||
@ -418,3 +416,8 @@ de:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: enthält ungültige Zeichen
|
||||
@ -168,8 +168,6 @@ en:
|
||||
permission_email_documents: Email documents
|
||||
label_file: File
|
||||
field_folder: Folder
|
||||
error_create_cycle_in_folder_dependency: create cycle in folder dependency
|
||||
error_contains_invalid_character: contains invalid character(s)
|
||||
error_file_commit_require_uploaded_file: File commit require uploaded file
|
||||
|
||||
warning_some_files_were_not_commited: "Some files were not commited due to validation errors: %{files}"
|
||||
@ -418,3 +416,8 @@ en:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: contains invalid character(s)
|
||||
@ -168,8 +168,6 @@ es:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Archivo
|
||||
field_folder: Directorio
|
||||
error_create_cycle_in_folder_dependency: crear ciclo en dependencia de directorio
|
||||
error_contains_invalid_character: contiene caracter(es) inválido(s)
|
||||
error_file_commit_require_uploaded_file: El commit requiere archivos subidos
|
||||
|
||||
warning_some_files_were_not_commited: "Algunos archivos no fueron registrados por un error de validación: %{files}"
|
||||
@ -418,3 +416,8 @@ es:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: contiene caracter(es) inválido(s)
|
||||
@ -168,8 +168,6 @@ fr:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Fichier
|
||||
field_folder: Dossier
|
||||
error_create_cycle_in_folder_dependency: Crée une dépendance cyclique du dossier
|
||||
error_contains_invalid_character: Contient un(des) caractère(s) invalide(s)
|
||||
error_file_commit_require_uploaded_file: "Transmission des fichiers nécessaire avant l'enregistrement"
|
||||
|
||||
warning_some_files_were_not_commited: "Erreur d'enregsitrement de certains fichiers %{files}"
|
||||
@ -418,3 +416,8 @@ fr:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: contient un(des) caractère(s) invalide(s)
|
||||
@ -168,8 +168,6 @@ hu:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Fájl
|
||||
field_folder: Mappa
|
||||
error_create_cycle_in_folder_dependency: hurok létrehozása a könyvtárstruktúrában
|
||||
error_contains_invalid_character: érvénytelen karaktereket tartalmaz
|
||||
error_file_commit_require_uploaded_file: Fájl beíratáshoz szükséges a feltöltött fájl
|
||||
|
||||
warning_some_files_were_not_commited: "Néhány fájl nem került beíratásra validálási locked_documents: Zárolt
|
||||
@ -418,3 +416,8 @@ hu:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: érvénytelen karaktereket tartalmaz
|
||||
@ -168,8 +168,6 @@ it: # Italian strings thx 2 Matteo Arceci!
|
||||
permission_email_documents: Email documents
|
||||
label_file: Documento
|
||||
field_folder: Cartella
|
||||
error_create_cycle_in_folder_dependency: crea un ciclo nella dipendenza della cartella
|
||||
error_contains_invalid_character: contiene carattere(i) non validi
|
||||
error_file_commit_require_uploaded_file: L'aggiornamento del documento richiede un documento già caricato in
|
||||
precedenza
|
||||
warning_some_files_were_not_commited: "Alcuni documenti non sono stati aggiornati a causa di errori di validazione:
|
||||
@ -418,3 +416,8 @@ it: # Italian strings thx 2 Matteo Arceci!
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: contiene carattere(i) non validi
|
||||
@ -168,8 +168,6 @@ ja:
|
||||
permission_email_documents: Email documents
|
||||
label_file: ファイル
|
||||
field_folder: フォルダ
|
||||
error_create_cycle_in_folder_dependency: フォルダの依存関係が循環しています
|
||||
error_contains_invalid_character: 無効な文字を含んでいます
|
||||
error_file_commit_require_uploaded_file: コミットするには、まずファイルをアップロードしてください
|
||||
|
||||
warning_some_files_were_not_commited: "いくつかのファイルは、バリデーションエラーのためにコミットされませんでした: %{files}"
|
||||
@ -418,3 +416,8 @@ ja:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: 無効な文字を含んでいます
|
||||
@ -168,8 +168,6 @@ ko:
|
||||
permission_email_documents: Email documents
|
||||
label_file: 파일
|
||||
field_folder: 폴더
|
||||
error_create_cycle_in_folder_dependency: 폴더 종속에 규칙 생성
|
||||
error_contains_invalid_character: 사용이 불가능한 문자(들) 포함
|
||||
error_file_commit_require_uploaded_file: 파일은 업로드 파일이 필요합니다
|
||||
|
||||
warning_some_files_were_not_commited: "다음 오류로 인하여 파일을 실행할 수 없습니다: %{files}"
|
||||
@ -418,3 +416,8 @@ ko:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: 사용이 불가능한 문자(들) 포함
|
||||
@ -168,8 +168,6 @@ nl:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Bestand
|
||||
field_folder: Map
|
||||
error_create_cycle_in_folder_dependency: maak cyclus in de map afhankelijkheid
|
||||
error_contains_invalid_character: bevat ongeldige teken(s)
|
||||
error_file_commit_require_uploaded_file: Bestand indienen vereist geüpload bestand
|
||||
|
||||
warning_some_files_were_not_commited: Sommige bestanden zijn niet ingediend door
|
||||
@ -418,3 +416,8 @@ nl:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: bevat ongeldige teken(s)
|
||||
@ -168,8 +168,7 @@ pl:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Plik
|
||||
field_folder: Folder
|
||||
error_create_cycle_in_folder_dependency: utworzono pętlę zależności pomiędzy folderami
|
||||
error_contains_invalid_character: zawiera nieprawidłowe znaki
|
||||
|
||||
error_file_commit_require_uploaded_file: Commit pliku wymaga jego uprzedniego przesłania
|
||||
|
||||
warning_some_files_were_not_commited: "Niektóre pliki nie zostały zacommitowane ze względu na błędy walidacji:
|
||||
@ -418,3 +417,8 @@ pl:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: zawiera nieprawidłowe znaki
|
||||
@ -168,8 +168,6 @@ pt-BR:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Arquivo
|
||||
field_folder: Pasta
|
||||
error_create_cycle_in_folder_dependency: Dependência entre pastas
|
||||
error_contains_invalid_character: Contém caracteres inválidos
|
||||
error_file_commit_require_uploaded_file: É necessário carregar um arquivo
|
||||
|
||||
warning_some_files_were_not_commited: "O(s) arquivo(s) não foram salvos: %{files}"
|
||||
@ -418,3 +416,8 @@ pt-BR:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: Contém caracteres inválidos
|
||||
@ -168,8 +168,6 @@ ru:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Файл
|
||||
field_folder: Папка
|
||||
error_create_cycle_in_folder_dependency: создать циклическую зависимость в папке
|
||||
error_contains_invalid_character: содержит недопустимые символы
|
||||
error_file_commit_require_uploaded_file: Чтобы зафиксировать файл нужно для начала его загрузить
|
||||
|
||||
warning_some_files_were_not_commited: "Некоторые файлы не были зафиксированы через ошибки валидации: %{files}"
|
||||
@ -418,3 +416,8 @@ ru:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: содержит недопустимые символы
|
||||
@ -168,8 +168,6 @@ sl:
|
||||
permission_email_documents: Email documents
|
||||
label_file: Datoteka
|
||||
field_folder: Pod mapo
|
||||
error_create_cycle_in_folder_dependency: naredi ciklično odvisnost med mapami
|
||||
error_contains_invalid_character: vsebuje nedovoljene znake
|
||||
error_file_commit_require_uploaded_file: Ukaz zahteva naloženo datoteko
|
||||
|
||||
warning_some_files_were_not_commited: "Nekatere datoteke niso shranje zaradi napak v validaciji: %{files}"
|
||||
@ -418,3 +416,8 @@ sl:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: vsebuje nedovoljene znake
|
||||
@ -168,8 +168,6 @@ zh-TW:
|
||||
permission_email_documents: Email documents
|
||||
label_file: 檔案
|
||||
field_folder: 資料夾
|
||||
error_create_cycle_in_folder_dependency: 資料夾之間的關係,不得為一個cycle循環。
|
||||
error_contains_invalid_character: 內有非法字元
|
||||
error_file_commit_require_uploaded_file: 檔案提交,需要上傳檔案。
|
||||
|
||||
warning_some_files_were_not_commited: "部份檔案因為驗証失敗無法提交: %{files}"
|
||||
@ -418,3 +416,8 @@ zh-TW:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: 內有非法字元
|
||||
@ -43,7 +43,7 @@ zh:
|
||||
error_folder_is_not_empty: 非空文件夹
|
||||
error_folder_title_is_already_used: 标题已经被使用
|
||||
notice_folder_details_were_saved: 文件夹详细信息已保存
|
||||
error_file_is_locked: Folder is locked
|
||||
error_folder_is_locked: 資料夾己經鎖定
|
||||
error_file_is_locked: 文件被锁定
|
||||
notice_file_deleted: 文件已删除
|
||||
error_at_least_one_revision_must_be_present: 至少一个修订版本必须存在
|
||||
@ -168,7 +168,6 @@ zh:
|
||||
permission_email_documents: Email documents
|
||||
label_file: 文件
|
||||
field_folder: 件夹
|
||||
error_create_cycle_in_folder_dependency: create cycle in folder dependency
|
||||
error_contains_invalid_character: 含有无效字符
|
||||
error_file_commit_require_uploaded_file: 文件提交要求上传文件
|
||||
|
||||
@ -418,3 +417,8 @@ zh:
|
||||
dmsf_open_approvals: My open approvals
|
||||
module_category:
|
||||
easy_dms: Easy DMS
|
||||
|
||||
activerecord:
|
||||
errors:
|
||||
messages:
|
||||
error_contains_invalid_character: 含有无效字符
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,83 +18,58 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CreateHierarchy < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
create_table :dmsf_folders do |t|
|
||||
t.references :project, :null => false
|
||||
t.references :project, null: false
|
||||
t.references :dmsf_folder
|
||||
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.text :description
|
||||
|
||||
t.boolean :notification, :default => false, :null => false
|
||||
|
||||
t.references :user, :null => false
|
||||
t.timestamps :null => false
|
||||
t.boolean :notification, default: false, null: false
|
||||
t.references :user, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :dmsf_files do |t|
|
||||
t.references :project, :null => false
|
||||
|
||||
t.references :project, null: false
|
||||
# This two fileds are copy from last revision due to simpler search
|
||||
t.references :dmsf_folder
|
||||
t.string :name, :null => false
|
||||
|
||||
t.boolean :notification, :default => false, :null => false
|
||||
|
||||
t.boolean :deleted, :default => false, :null => false
|
||||
t.string :name, null: false
|
||||
t.boolean :notification, default: false, null: false
|
||||
t.boolean :deleted, default: false, null: false
|
||||
t.integer :deleted_by_user_id
|
||||
|
||||
t.timestamps :null => false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :dmsf_file_revisions do |t|
|
||||
t.references :dmsf_file, :null => false
|
||||
t.references :dmsf_file, null: false
|
||||
t.integer :source_dmsf_file_revision_id
|
||||
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.references :dmsf_folder
|
||||
|
||||
t.string :disk_filename, :null => false
|
||||
t.string :disk_filename, null: false
|
||||
t.integer :size
|
||||
t.string :mime_type
|
||||
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.integer :workflow
|
||||
t.integer :major_version, :null => false
|
||||
t.integer :minor_version, :null => false
|
||||
t.integer :major_version, null: false
|
||||
t.integer :minor_version, null: false
|
||||
t.text :comment
|
||||
|
||||
t.boolean :deleted, :default => false, :null => false
|
||||
t.boolean :deleted, default: false, null: false
|
||||
t.integer :deleted_by_user_id
|
||||
|
||||
t.references :user, :null => false
|
||||
t.timestamps :null => false
|
||||
t.references :user, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :dmsf_file_locks do |t|
|
||||
t.references :dmsf_file, :null => false
|
||||
t.boolean :locked, :default => false, :null => false
|
||||
t.references :user, :null => false
|
||||
t.timestamps :null => false
|
||||
t.references :dmsf_file, null: false
|
||||
t.boolean :locked, default: false, null: false
|
||||
t.references :user, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :dmsf_user_prefs do |t|
|
||||
t.references :project, :null => false
|
||||
t.references :user, :null => false
|
||||
|
||||
t.references :project, null: false
|
||||
t.references :user, null: false
|
||||
t.boolean :email_notify
|
||||
|
||||
t.timestamps :null => false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :dmsf_file_revisions
|
||||
drop_table :dmsf_files
|
||||
drop_table :dmsf_folders
|
||||
drop_table :dmsf_file_locks
|
||||
drop_table :dmsf_user_prefs
|
||||
end
|
||||
end
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,11 +18,12 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class DmsfNormalization < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def up
|
||||
rename_column :dmsf_folders, :name, :title
|
||||
end
|
||||
|
||||
def self.down
|
||||
def down
|
||||
rename_column :dmsf_folders, :title, :name
|
||||
end
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,12 +18,9 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Dmsf080 < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
add_column :projects, :dmsf_description, :text
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :projects, :dmsf_description
|
||||
end
|
||||
|
||||
end
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,21 +18,19 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Dmsf090 < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def up
|
||||
add_column :members, :dmsf_mail_notification, :boolean
|
||||
drop_table :dmsf_user_prefs
|
||||
end
|
||||
|
||||
def self.down
|
||||
def own
|
||||
remove_column :members, :dmsf_mail_notification
|
||||
|
||||
create_table :dmsf_user_prefs do |t|
|
||||
t.references :project, :null => false
|
||||
t.references :user, :null => false
|
||||
|
||||
t.references :project, null: false
|
||||
t.references :user, null: false
|
||||
t.boolean :email_notify
|
||||
|
||||
t.timestamps :null => false
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,17 +18,14 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Dmsf0901 < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
create_table :dmsf_file_revision_accesses do |t|
|
||||
t.references :dmsf_file_revision, :null => false
|
||||
t.integer :action, :default => 0, :null => false # 0 ... download, 1 ... email
|
||||
t.references :user, :null => false
|
||||
t.timestamps :null => false
|
||||
t.references :dmsf_file_revision, null: false
|
||||
t.integer :action, :default => 0, null: false # 0 ... download, 1 ... email
|
||||
t.references :user, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :dmsf_file_revision_accesses
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -21,20 +21,19 @@
|
||||
|
||||
class Dmsf120 < ActiveRecord::Migration
|
||||
|
||||
def self.up
|
||||
add_column :dmsf_file_revisions, :project_id, :integer, :null => true
|
||||
def up
|
||||
add_column :dmsf_file_revisions, :project_id, :integer, null: true
|
||||
DmsfFileRevision.reset_column_information
|
||||
DmsfFileRevision.find_each do |revision|
|
||||
if revision.dmsf_file
|
||||
revision.project_id = revision.dmsf_file.project.id
|
||||
revision.save
|
||||
revision.save!
|
||||
end
|
||||
end
|
||||
|
||||
change_column :dmsf_file_revisions, :project_id, :integer, :null => false
|
||||
change_column :dmsf_file_revisions, :project_id, :integer, null: false
|
||||
end
|
||||
|
||||
def self.down
|
||||
def down
|
||||
remove_column :dmsf_file_revisions, :project_id
|
||||
end
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -21,24 +22,20 @@ require 'uuidtools'
|
||||
|
||||
class Dmsf144 < ActiveRecord::Migration
|
||||
|
||||
|
||||
class DmsfFileLock < ActiveRecord::Base
|
||||
belongs_to :file, :class_name => 'DmsfFile', :foreign_key => 'dmsf_file_id'
|
||||
belongs_to :file, class_name: 'DmsfFile', foreign_key: 'dmsf_file_id'
|
||||
belongs_to :user
|
||||
end
|
||||
|
||||
def self.up
|
||||
#Add our entity_type column (used with our entity type)
|
||||
add_column :dmsf_file_locks, :entity_type, :integer, :null => true
|
||||
|
||||
#Add our lock relevent columns (ENUM) - null (till we upgrade data)
|
||||
add_column :dmsf_file_locks, :lock_type_cd, :integer, :null => true
|
||||
add_column :dmsf_file_locks, :lock_scope_cd, :integer, :null => true
|
||||
add_column :dmsf_file_locks, :uuid, :string, :null => true, :limit => 36
|
||||
|
||||
#Add our expires_at column
|
||||
add_column :dmsf_file_locks, :expires_at, :datetime, :null => true
|
||||
|
||||
def up
|
||||
#A dd our entity_type column (used with our entity type)
|
||||
add_column :dmsf_file_locks, :entity_type, :integer, null: true
|
||||
# Add our lock relevent columns (ENUM) - null (till we upgrade data)
|
||||
add_column :dmsf_file_locks, :lock_type_cd, :integer, null: true
|
||||
add_column :dmsf_file_locks, :lock_scope_cd, :integer, null: true
|
||||
add_column :dmsf_file_locks, :uuid, :string, null: true, limit: 36
|
||||
# Add our expires_at column
|
||||
add_column :dmsf_file_locks, :expires_at, :datetime, null: true
|
||||
do_not_delete = []
|
||||
# - 2012-07-12: Better compatibility for postgres - query used 3 columns however
|
||||
# only on appearing in group, find_each imposes a limit and incorrect
|
||||
@ -46,48 +43,37 @@ class Dmsf144 < ActiveRecord::Migration
|
||||
# data into it, which should enable us to run checks we need, not as
|
||||
# efficient, however compatible across the board.
|
||||
DmsfFileLock.reset_column_information
|
||||
DmsfFileLock.select('MAX(id), id').
|
||||
order('MAX(id) DESC').
|
||||
group(:dmsf_file_id, :id).
|
||||
each do |lock|
|
||||
DmsfFileLock.select('MAX(id), id').order('MAX(id) DESC').group(:dmsf_file_id, :id).find do |lock|
|
||||
lock.reload
|
||||
if (lock.locked)
|
||||
if lock.locked
|
||||
do_not_delete << lock.id
|
||||
end
|
||||
end
|
||||
|
||||
#Generate new lock Id's for whats being persisted
|
||||
do_not_delete.each {|l|
|
||||
#Find the lock
|
||||
# Generate new lock Id's for whats being persisted
|
||||
do_not_delete.each do |l|
|
||||
# Find the lock
|
||||
next unless lock = DmsfFileLock.find(l)
|
||||
lock.uuid = UUIDTools::UUID.random_create.to_s
|
||||
lock.save!
|
||||
}
|
||||
|
||||
end
|
||||
say "Preserving #{do_not_delete.count} file lock(s) found in old schema"
|
||||
|
||||
DmsfFileLock.where(['id NOT IN (?)', do_not_delete]).delete_all
|
||||
|
||||
#We need to force our newly found
|
||||
|
||||
DmsfFileLock.where.not(id: do_not_delete).delete_all
|
||||
# We need to force our newly found
|
||||
say 'Applying default lock scope / type - Exclusive / Write'
|
||||
DmsfFileLock.update_all ['entity_type = ?, lock_type_cd = ?, lock_scope_cd = ?', 0, 0, 0]
|
||||
|
||||
#These are not null-allowed columns
|
||||
change_column :dmsf_file_locks, :entity_type, :integer, :null => false
|
||||
change_column :dmsf_file_locks, :lock_type_cd, :integer, :null => false
|
||||
change_column :dmsf_file_locks, :lock_scope_cd, :integer, :null => false
|
||||
|
||||
#Data cleanup
|
||||
DmsfFileLock.update_all(entity_type: 0, lock_type_cd: 0, lock_scope_cd: 0)
|
||||
# These are not null-allowed columns
|
||||
change_column :dmsf_file_locks, :entity_type, :integer, null: false
|
||||
change_column :dmsf_file_locks, :lock_type_cd, :integer, null: false
|
||||
change_column :dmsf_file_locks, :lock_scope_cd, :integer, null: false
|
||||
# Data cleanup
|
||||
rename_column :dmsf_file_locks, :dmsf_file_id, :entity_id
|
||||
remove_column :dmsf_file_locks, :locked
|
||||
rename_table :dmsf_file_locks, :dmsf_locks
|
||||
|
||||
#Not sure if this is the right place to do this, as its file manipulation, not database (strictly)
|
||||
say "Completing one-time file migration ..."
|
||||
# Not sure if this is the right place to do this, as its file manipulation, not database (strictly)
|
||||
say 'Completing one-time file migration ...'
|
||||
begin
|
||||
DmsfFileRevision.visible.each {|rev|
|
||||
next if rev.project.nil?
|
||||
DmsfFileRevision.visible.find_each do |rev|
|
||||
next unless rev.project
|
||||
existing = DmsfFile.storage_path.join rev.disk_filename
|
||||
new_path = rev.disk_file(false)
|
||||
begin
|
||||
@ -97,7 +83,7 @@ class Dmsf144 < ActiveRecord::Migration
|
||||
new_path = rev.disk_file(false)
|
||||
rev.save!
|
||||
end
|
||||
#Ensure the project path exists
|
||||
# Ensure the project path exists
|
||||
project_directory = File.dirname(new_path)
|
||||
Dir.mkdir(project_directory) unless File.directory? project_directory
|
||||
FileUtils.mv(existing, new_path)
|
||||
@ -106,42 +92,37 @@ class Dmsf144 < ActiveRecord::Migration
|
||||
rescue #Here we wrap around IO in the loop to prevent one failure ruining complete run.
|
||||
say "Migration: #{existing} -> #{new_path} failed"
|
||||
end
|
||||
}
|
||||
end
|
||||
say 'Action was successful'
|
||||
rescue Exception => e
|
||||
say 'Action was not successful'
|
||||
puts e.message
|
||||
puts e.backtrace.inspect #See issue 86
|
||||
#Nothing here, we just dont want a migration to break
|
||||
puts e.backtrace.inspect # See issue #86
|
||||
# Nothing here, we just dont want a migration to break
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
rename_table :dmsf_locks, :dmsf_file_locks
|
||||
add_column :dmsf_file_locks, :locked, :boolean, :default => false, :null => false
|
||||
|
||||
#Data cleanup - delete all expired locks, or any folder locks
|
||||
add_column :dmsf_file_locks, :locked, :boolean, default: false, null: false
|
||||
# Data cleanup - delete all expired locks, or any folder locks
|
||||
DmsfFileLock.reset_column_information
|
||||
say 'Removing all expired and/or folder locks'
|
||||
DmsfFileLock.where(['expires_at < ? OR entity_type = 1', Time.now]).delete_all
|
||||
|
||||
DmsfFileLock.where(['expires_at < ? OR entity_type = 1', Time.current]).delete_all
|
||||
say 'Changing all records to be locked'
|
||||
DmsfFileLock.update_all ['locked = ?', true]
|
||||
|
||||
DmsfFileLock.update_all(locked: true)
|
||||
rename_column :dmsf_file_locks, :entity_id, :dmsf_file_id
|
||||
|
||||
remove_column :dmsf_file_locks, :entity_type
|
||||
remove_column :dmsf_file_locks, :lock_type_cd
|
||||
remove_column :dmsf_file_locks, :lock_scope_cd
|
||||
remove_column :dmsf_file_locks, :expires_at
|
||||
remove_column :dmsf_file_locks, :uuid
|
||||
|
||||
#Not sure if this is the right place to do this, as its file manipulation, not database (stricly)
|
||||
# Not sure if this is the right place to do this, as its file manipulation, not database (stricly)
|
||||
begin
|
||||
say 'restoring old file-structure'
|
||||
DmsfFileRevision.visible.each {|rev|
|
||||
next if rev.project.nil?
|
||||
project = rev.project.identifier.gsub(/[^\w\.\-]/,'_')
|
||||
DmsfFileRevision.visible.find_each do |rev|
|
||||
next unless rev.project
|
||||
project = rev.project.identifier.gsub(/[^\w\.\-]/, '_')
|
||||
existing = DmsfFile.storage_path.join("p_#{project}/#{rev.disk_filename}")
|
||||
new_path = DmsfFile.storage_path.join(rev.disk_filename)
|
||||
if File.exist?(existing)
|
||||
@ -152,9 +133,9 @@ class Dmsf144 < ActiveRecord::Migration
|
||||
end
|
||||
FileUtils.mv(existing, new_path)
|
||||
end
|
||||
}
|
||||
end
|
||||
rescue
|
||||
#Nothing here, we just dont want a migration to break
|
||||
# Nothing here, we just dont want a migration to break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -19,12 +20,13 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CreateDmsfWorkflows < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def up
|
||||
create_table :dmsf_workflows do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.references :project
|
||||
end
|
||||
add_index :dmsf_workflows, [:name], :unique => true
|
||||
add_index :dmsf_workflows, [:name], unique: true, name: :index_dmsf_workflows_on_name
|
||||
|
||||
change_table :dmsf_file_revisions do |t|
|
||||
t.references :dmsf_workflow
|
||||
@ -35,7 +37,7 @@ class CreateDmsfWorkflows < ActiveRecord::Migration
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
def down
|
||||
remove_column :dmsf_file_revisions, :dmsf_workflow_id
|
||||
remove_column :dmsf_file_revisions, :dmsf_workflow_assigned_by
|
||||
remove_column :dmsf_file_revisions, :dmsf_workflow_assigned_at
|
||||
@ -43,4 +45,5 @@ class CreateDmsfWorkflows < ActiveRecord::Migration
|
||||
remove_column :dmsf_file_revisions, :dmsf_workflow_started_at
|
||||
drop_table :dmsf_workflows
|
||||
end
|
||||
|
||||
end
|
||||
@ -19,17 +19,15 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CreateDmsfWorkflowSteps < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
create_table :dmsf_workflow_steps do |t|
|
||||
t.references :dmsf_workflow, :null => false
|
||||
t.integer :step, :null => false
|
||||
t.references :user, :null => false
|
||||
t.integer :operator, :null => false
|
||||
t.references :dmsf_workflow, null: false
|
||||
t.integer :step, null: false
|
||||
t.references :user, null: false
|
||||
t.integer :operator, null: false
|
||||
end
|
||||
add_index :dmsf_workflow_steps, :dmsf_workflow_id
|
||||
add_index :dmsf_workflow_steps, :dmsf_workflow_id, name: :index_dmsf_workflow_steps_on_dmsf_workflow_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :dmsf_workflow_steps
|
||||
end
|
||||
end
|
||||
@ -19,20 +19,18 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CreateDmsfWorkflowStepAssignments < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
create_table :dmsf_workflow_step_assignments do |t|
|
||||
t.references :dmsf_workflow_step, :null => false
|
||||
t.references :user, :null => false
|
||||
t.references :dmsf_file_revision, :null => false
|
||||
t.references :dmsf_workflow_step, null: false
|
||||
t.references :user, null: false
|
||||
t.references :dmsf_file_revision, null: false
|
||||
end
|
||||
add_index :dmsf_workflow_step_assignments,
|
||||
[:dmsf_workflow_step_id, :dmsf_file_revision_id],
|
||||
# The default index name exceeds the index name limit
|
||||
:name => 'index_dmsf_wrkfl_step_assigns_on_wrkfl_step_id_and_frev_id',
|
||||
:unique => true
|
||||
name: :index_dmsf_wrkfl_step_assigns_on_wrkfl_step_id_and_frev_id,
|
||||
unique: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :dmsf_workflow_step_assignments
|
||||
end
|
||||
end
|
||||
@ -19,20 +19,19 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CreateDmsfWorkflowStepActions < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
def change
|
||||
create_table :dmsf_workflow_step_actions do |t|
|
||||
t.references :dmsf_workflow_step_assignment, :null => false
|
||||
t.integer :action, :null => false
|
||||
t.references :dmsf_workflow_step_assignment, null: false
|
||||
t.integer :action, null: false
|
||||
t.text :note
|
||||
t.timestamp :created_at, :null => false
|
||||
t.integer :author_id, :null => false
|
||||
t.timestamp :created_at, null: false
|
||||
t.integer :author_id, null: false
|
||||
end
|
||||
add_index :dmsf_workflow_step_actions,
|
||||
:dmsf_workflow_step_assignment_id,
|
||||
# The default index name exceeds the index name limit
|
||||
{:name => 'idx_dmsf_wfstepact_on_wfstepassign_id'}
|
||||
end
|
||||
def self.down
|
||||
drop_table :dmsf_workflow_step_actions
|
||||
name: :idx_dmsf_wfstepact_on_wfstepassign_id
|
||||
end
|
||||
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user