Database normalisation #301
This commit is contained in:
parent
fdd70c7d66
commit
4f564abd2a
@ -36,9 +36,8 @@ class DmsfController < ApplicationController
|
|||||||
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
||||||
@file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project)
|
@file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project)
|
||||||
@file_delete_allowed = User.current.allowed_to?(:file_delete, @project)
|
@file_delete_allowed = User.current.allowed_to?(:file_delete, @project)
|
||||||
@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project)
|
@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project)
|
||||||
|
@workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).count > 0
|
||||||
@workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).count > 0
|
|
||||||
|
|
||||||
unless @folder
|
unless @folder
|
||||||
if params[:custom_field_id].present? && params[:custom_value].present?
|
if params[:custom_field_id].present? && params[:custom_value].present?
|
||||||
@ -105,9 +104,16 @@ class DmsfController < ApplicationController
|
|||||||
@dir_links = @folder.folder_links.visible
|
@dir_links = @folder.folder_links.visible
|
||||||
@file_links = @folder.file_links.visible
|
@file_links = @folder.file_links.visible
|
||||||
@locked_for_user = @folder.locked_for_user?
|
@locked_for_user = @folder.locked_for_user?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100
|
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100
|
||||||
|
|
||||||
|
# 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, :target_type => DmsfFolder.model_name).any? ||
|
||||||
|
DmsfLink.deleted.where(:project_id => @project.id, :target_type => DmsfFile.model_name).any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def trash
|
def trash
|
||||||
@ -254,7 +260,7 @@ class DmsfController < ApplicationController
|
|||||||
if @folder.delete(commit)
|
if @folder.delete(commit)
|
||||||
flash[:notice] = l(:notice_folder_deleted)
|
flash[:notice] = l(:notice_folder_deleted)
|
||||||
else
|
else
|
||||||
flash[:error] = @folder.errors[:base][0]
|
flash[:error] = @folder.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
if commit
|
if commit
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
@ -267,7 +273,7 @@ class DmsfController < ApplicationController
|
|||||||
if @folder.restore
|
if @folder.restore
|
||||||
flash[:notice] = l(:notice_dmsf_folder_restored)
|
flash[:notice] = l(:notice_dmsf_folder_restored)
|
||||||
else
|
else
|
||||||
flash[:error] = @folder.errors[:base][0]
|
flash[:error] = @folder.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
end
|
end
|
||||||
@ -442,7 +448,7 @@ class DmsfController < ApplicationController
|
|||||||
folder = DmsfFolder.find_by_id id
|
folder = DmsfFolder.find_by_id id
|
||||||
if folder
|
if folder
|
||||||
unless folder.restore
|
unless folder.restore
|
||||||
flash[:error] = folder.errors[:base][0]
|
flash[:error] = folder.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise FileNotFound
|
raise FileNotFound
|
||||||
@ -453,7 +459,7 @@ class DmsfController < ApplicationController
|
|||||||
file = DmsfFile.find_by_id id
|
file = DmsfFile.find_by_id id
|
||||||
if file
|
if file
|
||||||
unless file.restore
|
unless file.restore
|
||||||
flash[:error] = file.errors[:base][0]
|
flash[:error] = file.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise FileNotFound
|
raise FileNotFound
|
||||||
@ -464,7 +470,7 @@ class DmsfController < ApplicationController
|
|||||||
link = DmsfLink.find_by_id id
|
link = DmsfLink.find_by_id id
|
||||||
if link
|
if link
|
||||||
unless link.restore
|
unless link.restore
|
||||||
flash[:error] = link.errors[:base][0]
|
flash[:error] = link.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise FileNotFound
|
raise FileNotFound
|
||||||
@ -478,7 +484,7 @@ class DmsfController < ApplicationController
|
|||||||
folder = DmsfFolder.find_by_id id
|
folder = DmsfFolder.find_by_id id
|
||||||
if folder
|
if folder
|
||||||
unless folder.delete commit
|
unless folder.delete commit
|
||||||
flash[:error] = folder.errors[:base][0]
|
flash[:error] = folder.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise FileNotFound
|
raise FileNotFound
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
@ -76,38 +76,36 @@ class DmsfFilesController < ApplicationController
|
|||||||
if @file.locked_for_user?
|
if @file.locked_for_user?
|
||||||
flash[:error] = l(:error_file_is_locked)
|
flash[:error] = l(:error_file_is_locked)
|
||||||
else
|
else
|
||||||
@revision = DmsfFileRevision.new(params[:dmsf_file_revision])
|
revision = DmsfFileRevision.new(params[:dmsf_file_revision])
|
||||||
|
|
||||||
@revision.file = @file
|
revision.file = @file
|
||||||
@revision.project = @file.project
|
|
||||||
last_revision = @file.last_revision
|
last_revision = @file.last_revision
|
||||||
@revision.source_revision = last_revision
|
revision.source_revision = last_revision
|
||||||
@revision.user = User.current
|
revision.user = User.current
|
||||||
|
|
||||||
@revision.major_version = last_revision.major_version
|
revision.major_version = last_revision.major_version
|
||||||
@revision.minor_version = last_revision.minor_version
|
revision.minor_version = last_revision.minor_version
|
||||||
version = params[:version].to_i
|
version = params[:version].to_i
|
||||||
file_upload = params[:file_upload]
|
file_upload = params[:file_upload]
|
||||||
unless file_upload
|
unless file_upload
|
||||||
@revision.disk_filename = last_revision.disk_filename
|
revision.disk_filename = last_revision.disk_filename
|
||||||
@revision.increase_version(version, false)
|
revision.increase_version(version, false)
|
||||||
@revision.mime_type = last_revision.mime_type
|
revision.mime_type = last_revision.mime_type
|
||||||
@revision.size = last_revision.size
|
revision.size = last_revision.size
|
||||||
else
|
else
|
||||||
@revision.increase_version(version, true)
|
revision.increase_version(version, true)
|
||||||
@revision.size = file_upload.size
|
revision.size = file_upload.size
|
||||||
@revision.disk_filename = @revision.new_storage_filename
|
revision.disk_filename = revision.new_storage_filename
|
||||||
@revision.mime_type = Redmine::MimeType.of(file_upload.original_filename)
|
revision.mime_type = Redmine::MimeType.of(file_upload.original_filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
@file.name = @revision.name
|
@file.name = revision.name
|
||||||
@file.folder = @revision.folder
|
|
||||||
|
|
||||||
if @revision.valid? && @file.valid?
|
if revision.valid? && @file.valid?
|
||||||
@revision.save!
|
revision.save!
|
||||||
@revision.assign_workflow(params[:dmsf_workflow_id])
|
revision.assign_workflow(params[:dmsf_workflow_id])
|
||||||
if file_upload
|
if file_upload
|
||||||
@revision.copy_file_content(file_upload)
|
revision.copy_file_content(file_upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @file.locked? && !@file.locks.empty?
|
if @file.locked? && !@file.locks.empty?
|
||||||
@ -119,7 +117,7 @@ class DmsfFilesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@file.save!
|
@file.save!
|
||||||
@file.set_last_revision @revision
|
@file.set_last_revision revision
|
||||||
|
|
||||||
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
|
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
|
||||||
log_activity('new revision')
|
log_activity('new revision')
|
||||||
@ -235,7 +233,7 @@ class DmsfFilesController < ApplicationController
|
|||||||
log_activity('restored')
|
log_activity('restored')
|
||||||
flash[:notice] = l(:notice_dmsf_file_restored)
|
flash[:notice] = l(:notice_dmsf_file_restored)
|
||||||
else
|
else
|
||||||
flash[:error] = @file.errors[:base][0]
|
flash[:error] = @file.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
end
|
end
|
||||||
|
|||||||
@ -115,9 +115,7 @@ class DmsfUploadController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
commited_disk_filepath = "#{DmsfHelper.temp_dir}/#{commited_file[:disk_filename].gsub(/[\/\\]/,'')}"
|
commited_disk_filepath = "#{DmsfHelper.temp_dir}/#{commited_file[:disk_filename].gsub(/[\/\\]/,'')}"
|
||||||
|
|
||||||
new_revision.project = link ? link.target_project : @project
|
|
||||||
new_revision.folder = link ? link.target_folder : @folder
|
|
||||||
new_revision.file = file
|
new_revision.file = file
|
||||||
new_revision.user = User.current
|
new_revision.user = User.current
|
||||||
new_revision.name = name
|
new_revision.name = name
|
||||||
|
|||||||
@ -355,7 +355,7 @@ private
|
|||||||
@project = @dmsf_workflow.project
|
@project = @dmsf_workflow.project
|
||||||
else # Global workflow
|
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.project if revision
|
@project = revision.file.project if revision && revision.file
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if params[:project_id].present?
|
if params[:project_id].present?
|
||||||
|
|||||||
@ -202,42 +202,49 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
new_revision = self.last_revision.clone
|
# If the target project differs from the source project we must physically move the disk files
|
||||||
|
if self.project != project
|
||||||
new_revision.folder = folder
|
self.revisions.all.each do |rev|
|
||||||
new_revision.project = folder ? folder.project : project
|
if File.exist? rev.disk_file(self.project)
|
||||||
new_revision.comment = l(:comment_moved_from, :source => "#{self.project.identifier}:#{self.dmsf_path_str}")
|
FileUtils.mv rev.disk_file(self.project), rev.disk_file(project)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.project = project
|
||||||
|
self.folder = folder
|
||||||
|
new_revision = self.last_revision.clone
|
||||||
|
new_revision.file = self
|
||||||
|
new_revision.comment = l(:comment_moved_from, :source => "#{self.project.identifier}:#{self.dmsf_path_str}")
|
||||||
new_revision.custom_values = []
|
new_revision.custom_values = []
|
||||||
|
|
||||||
self.last_revision.custom_values.each do |cv|
|
self.last_revision.custom_values.each do |cv|
|
||||||
new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
||||||
end
|
end
|
||||||
|
|
||||||
# If the target project differs from the source project we must physically copy the file
|
self.save && new_revision.save
|
||||||
if self.project != new_revision.project
|
|
||||||
if File.exist? self.last_revision.disk_file
|
|
||||||
FileUtils.cp self.last_revision.disk_file, new_revision.disk_file
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.folder = new_revision.folder
|
|
||||||
self.project = new_revision.project
|
|
||||||
|
|
||||||
self.save && new_revision.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_to(project, folder)
|
def copy_to(project, folder)
|
||||||
|
|
||||||
|
# If the target project differs from the source project we must physically move the disk files
|
||||||
|
if self.project != project
|
||||||
|
self.revisions.all.each do |rev|
|
||||||
|
if File.exist? rev.disk_file(self.project)
|
||||||
|
FileUtils.cp rev.disk_file(self.project), rev.disk_file(project)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
file = DmsfFile.new
|
file = DmsfFile.new
|
||||||
file.folder = folder
|
file.folder = folder
|
||||||
file.project = folder ? folder.project : project
|
file.project = project
|
||||||
file.name = self.name
|
file.name = self.name
|
||||||
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
||||||
|
|
||||||
if file.save && self.last_revision
|
if file.save && self.last_revision
|
||||||
new_revision = self.last_revision.clone
|
new_revision = self.last_revision.clone
|
||||||
new_revision.file = file
|
new_revision.file = file
|
||||||
new_revision.folder = folder
|
|
||||||
new_revision.project = folder ? folder.project : project
|
|
||||||
new_revision.comment = l(:comment_copied_from, :source => "#{self.project.identifier}: #{self.dmsf_path_str}")
|
new_revision.comment = l(:comment_copied_from, :source => "#{self.project.identifier}: #{self.dmsf_path_str}")
|
||||||
|
|
||||||
new_revision.custom_values = []
|
new_revision.custom_values = []
|
||||||
@ -245,22 +252,13 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
new_revision.custom_values << CustomValue.new({:custom_field => cv.custom_field, :value => cv.value})
|
||||||
end
|
end
|
||||||
|
|
||||||
unless new_revision.save
|
file.delete(true) unless new_revision.save
|
||||||
file.delete
|
|
||||||
else
|
|
||||||
# If the target project differs from the source project we must physically copy the file
|
|
||||||
if project != self.project
|
|
||||||
if File.exist? self.last_revision.disk_file
|
|
||||||
FileUtils.cp self.last_revision.disk_file, new_revision.disk_file
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return file
|
return file
|
||||||
end
|
end
|
||||||
|
|
||||||
# To fullfill searchable module expectations
|
# To fulfill searchable module expectations
|
||||||
def self.search(tokens, projects = nil, options = {})
|
def self.search(tokens, projects = nil, options = {})
|
||||||
tokens = [] << tokens unless tokens.is_a?(Array)
|
tokens = [] << tokens unless tokens.is_a?(Array)
|
||||||
projects = [] << projects unless projects.nil? || projects.is_a?(Array)
|
projects = [] << projects unless projects.nil? || projects.is_a?(Array)
|
||||||
|
|||||||
@ -23,8 +23,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
belongs_to :source_revision, :class_name => 'DmsfFileRevision', :foreign_key => 'source_dmsf_file_revision_id'
|
belongs_to :source_revision, :class_name => 'DmsfFileRevision', :foreign_key => 'source_dmsf_file_revision_id'
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id'
|
belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id'
|
||||||
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
||||||
belongs_to :project
|
|
||||||
has_many :access, :class_name => 'DmsfFileRevisionAccess', :foreign_key => 'dmsf_file_revision_id', :dependent => :destroy
|
has_many :access, :class_name => 'DmsfFileRevisionAccess', :foreign_key => 'dmsf_file_revision_id', :dependent => :destroy
|
||||||
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
|
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
|
||||||
|
|
||||||
@ -53,6 +52,14 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
validates_format_of :name, :with => DmsfFolder.invalid_characters,
|
validates_format_of :name, :with => DmsfFolder.invalid_characters,
|
||||||
:message => l(:error_contains_invalid_character)
|
:message => l(:error_contains_invalid_character)
|
||||||
|
|
||||||
|
def project
|
||||||
|
self.file.project if self.file
|
||||||
|
end
|
||||||
|
|
||||||
|
def folder
|
||||||
|
self.file.folder if self.file
|
||||||
|
end
|
||||||
|
|
||||||
def self.remove_extension(filename)
|
def self.remove_extension(filename)
|
||||||
filename[0, (filename.length - File.extname(filename).length)]
|
filename[0, (filename.length - File.extname(filename).length)]
|
||||||
end
|
end
|
||||||
@ -117,9 +124,10 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
"#{self.major_version}.#{self.minor_version}"
|
"#{self.major_version}.#{self.minor_version}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def disk_file
|
def disk_file(project = nil)
|
||||||
storage_base = "#{DmsfFile.storage_path}" #perhaps .dup?
|
project = self.file.project unless project
|
||||||
unless project.nil?
|
storage_base = DmsfFile.storage_path.dup
|
||||||
|
if self.file && project
|
||||||
project_base = project.identifier.gsub(/[^\w\.\-]/,'_')
|
project_base = project.identifier.gsub(/[^\w\.\-]/,'_')
|
||||||
storage_base << "/p_#{project_base}"
|
storage_base << "/p_#{project_base}"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -89,10 +89,8 @@
|
|||||||
:title => l(:link_create_folder),
|
:title => l(:link_create_folder),
|
||||||
:class => 'icon icon-add') unless @locked_for_user %>
|
:class => 'icon icon-add') unless @locked_for_user %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to(l(:link_trash_bin),
|
<%= link_to_if(@trash_enabled, l(:link_trash_bin), trash_dmsf_path(@project),
|
||||||
trash_dmsf_path(@project),
|
:title => l(:link_trash_bin), :class => 'icon icon-del') if @trash_visible %>
|
||||||
:title => l(:link_trash_bin),
|
|
||||||
:class => 'icon icon-del') unless @locked_for_user unless @folder %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render(:partial => 'path', :locals => {:folder => @folder, :filename => nil}) %>
|
<%= render(:partial => 'path', :locals => {:folder => @folder, :filename => nil}) %>
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<%#=
|
<%#=
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||||
# Copyright (C) 2013 Karel Pičman <karel.picman@kontron.com>
|
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -37,11 +37,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<p style="white-space: nowrap;">
|
<p style="white-space: nowrap;">
|
||||||
<%= label_tag('', "#{l(:label_file)}:") %>
|
<%= label_tag('', "#{l(:label_file)}:") %>
|
||||||
<%= f.select(:dmsf_folder_id,
|
<%= f.text_field(:name, :size => 22) %>
|
||||||
options_for_select(DmsfFolder.directory_tree(@project),
|
|
||||||
:selected => (@revision.folder.id if @revision.folder))) %> /
|
|
||||||
<%= f.text_field(:name, :size => 22) %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -99,7 +99,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<%= label_tag('', "#{l(:label_file)}:") %>
|
<%= label_tag('', "#{l(:label_file)}:") %>
|
||||||
<%= ("#{h(revision.folder.dmsf_path_str)}/") if revision.folder %><%= h(revision.name) %>
|
<%= ("#{h(revision.file.folder.dmsf_path_str)}/") if revision.file.folder %><%= h(revision.name) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="no-ident">
|
<p class="no-ident">
|
||||||
|
|||||||
@ -22,12 +22,12 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= @text2 %>
|
<%= @text2 %>
|
||||||
<% unless @revision.folder %>
|
<% unless @revision.file.folder %>
|
||||||
<%= link_to l(:link_documents),
|
<%= link_to l(:link_documents),
|
||||||
dmsf_folder_path(:id => @revision.file.project, :only_path => false) %>
|
dmsf_folder_path(:id => @revision.file.project, :only_path => false) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to @revision.folder.title,
|
<%= link_to @revision.file.folder.title,
|
||||||
dmsf_folder_path(:id => @revision.file.project, :folder_id => @revision.folder, :only_path => false) %>
|
dmsf_folder_path(:id => @revision.file.project, :folder_id => @revision.file.folder, :only_path => false) %>
|
||||||
<% end %>.
|
<% end %>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
<%= @user.name %>,
|
<%= @user.name %>,
|
||||||
<%= @text1 %>
|
<%= @text1 %>
|
||||||
<% unless @revision.folder %>
|
<% unless @revision.file.folder %>
|
||||||
<%= @text2 %> <%= dmsf_folder_path(:id => @revision.file.project, :only_path => false) %>.
|
<%= @text2 %> <%= dmsf_folder_path(:id => @revision.file.project, :only_path => false) %>.
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= @text2 %> <%= dmsf_folder_path(:id => @revision.file.project, :folder_id => @revision.folder, :only_path => false) %>.
|
<%= @text2 %> <%= dmsf_folder_path(:id => @revision.file.project, :folder_id => @revision.file.folder, :only_path => false) %>.
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -43,8 +43,8 @@
|
|||||||
<% assignments.each do |assignment| %>
|
<% assignments.each do |assignment| %>
|
||||||
<tr id="assignment-<%= assignment.id %>" class="<%= cycle('odd', 'even') %>">
|
<tr id="assignment-<%= assignment.id %>" class="<%= cycle('odd', 'even') %>">
|
||||||
<td class="project">
|
<td class="project">
|
||||||
<% if assignment.dmsf_file_revision.project %>
|
<% if assignment.dmsf_file_revision.file.project %>
|
||||||
<%= link_to_project(assignment.dmsf_file_revision.project) %>
|
<%= link_to_project(assignment.dmsf_file_revision.file.project) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -61,11 +61,11 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="title">
|
<td class="title">
|
||||||
<% if assignment.dmsf_file_revision %>
|
<% if assignment.dmsf_file_revision %>
|
||||||
<% if assignment.dmsf_file_revision.folder %>
|
<% if assignment.dmsf_file_revision.file.folder %>
|
||||||
<%= link_to(h(assignment.dmsf_file_revision.folder.title),
|
<%= link_to(h(assignment.dmsf_file_revision.file.folder.title),
|
||||||
{:controller => 'dmsf', :action => 'show', :id=> assignment.dmsf_file_revision.project, :folder_id => assignment.dmsf_file_revision.folder}) %>
|
{:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.file.project, :folder_id => assignment.dmsf_file_revision.file.folder}) %>
|
||||||
<% elsif assignment.dmsf_file_revision.project %>
|
<% elsif assignment.dmsf_file_revision.file.project %>
|
||||||
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.project }) %>
|
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.file.project }) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class Dmsf120 < ActiveRecord::Migration
|
|||||||
|
|
||||||
DmsfFileRevision.find_each do |revision|
|
DmsfFileRevision.find_each do |revision|
|
||||||
if revision.file
|
if revision.file
|
||||||
revision.project = revision.file.project
|
revision.project_id = revision.file.project.id
|
||||||
revision.save
|
revision.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
36
db/migrate/20141013102501_remove_project_from_revision.rb
Normal file
36
db/migrate/20141013102501_remove_project_from_revision.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-14 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 RemoveProjectFromRevision < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :dmsf_file_revisions, :project_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_column :dmsf_file_revisions, :project_id, :integer, :null => true
|
||||||
|
|
||||||
|
DmsfFileRevision.find_each do |revision|
|
||||||
|
if revision.file
|
||||||
|
revision.project_id = revision.file.project_id
|
||||||
|
revision.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
change_column :dmsf_file_revisions, :project_id, :integer, :null => false
|
||||||
|
end
|
||||||
|
end
|
||||||
34
db/migrate/20141015132701_remove_folder_from_revision.rb
Normal file
34
db/migrate/20141015132701_remove_folder_from_revision.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-14 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 RemoveFolderFromRevision < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :dmsf_file_revisions, :dmsf_folder_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_column :dmsf_file_revisions, :dmsf_folder_id, :integer, :null => true
|
||||||
|
|
||||||
|
DmsfFileRevision.find_each do |revision|
|
||||||
|
if revision.file
|
||||||
|
revision.dmsf_folder_id = revision.file.dmsf_folder_id
|
||||||
|
revision.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -514,9 +514,7 @@ module RedmineDmsf
|
|||||||
new_revision.minor_version = 0
|
new_revision.minor_version = 0
|
||||||
new_revision.major_version = 0
|
new_revision.major_version = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
new_revision.project = project
|
|
||||||
new_revision.folder = parent.folder
|
|
||||||
new_revision.file = f
|
new_revision.file = f
|
||||||
new_revision.user = User.current
|
new_revision.user = User.current
|
||||||
new_revision.name = basename
|
new_revision.name = basename
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
|
# Copyright (C) 2011-14 Karel Picman <karel.picman@kontron.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -126,9 +127,7 @@ class DmsfConvertDocuments
|
|||||||
|
|
||||||
revision = DmsfFileRevision.new
|
revision = DmsfFileRevision.new
|
||||||
revision.file = file
|
revision.file = file
|
||||||
revision.name = file.name
|
revision.name = file.name
|
||||||
revision.folder = file.folder
|
|
||||||
revision.project = file.project
|
|
||||||
revision.title = DmsfFileRevision.filename_to_title(attachment.filename)
|
revision.title = DmsfFileRevision.filename_to_title(attachment.filename)
|
||||||
revision.description = attachment.description
|
revision.description = attachment.description
|
||||||
revision.user = attachment.author
|
revision.user = attachment.author
|
||||||
|
|||||||
30
test/fixtures/dmsf_file_revisions.yml
vendored
30
test/fixtures/dmsf_file_revisions.yml
vendored
@ -3,8 +3,7 @@ dmsf_file_revisions_001:
|
|||||||
id: 1
|
id: 1
|
||||||
dmsf_file_id: 1
|
dmsf_file_id: 1
|
||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "test.txt"
|
name: "test.txt"
|
||||||
dmsf_folder_id: NULL
|
|
||||||
disk_filename: "test.txt"
|
disk_filename: "test.txt"
|
||||||
size: 4
|
size: 4
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
@ -18,16 +17,14 @@ dmsf_file_revisions_001:
|
|||||||
deleted_by_user_id: NULL
|
deleted_by_user_id: NULL
|
||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by: 1
|
dmsf_workflow_assigned_by: 1
|
||||||
dmsf_workflow_started_by: 1
|
dmsf_workflow_started_by: 1
|
||||||
project_id: 1
|
|
||||||
|
|
||||||
#revision for file on non-enabled project
|
#revision for file on non-enabled project
|
||||||
dmsf_file_revisions_002:
|
dmsf_file_revisions_002:
|
||||||
id: 2
|
id: 2
|
||||||
dmsf_file_id: 2
|
dmsf_file_id: 2
|
||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "test.txt"
|
name: "test.txt"
|
||||||
dmsf_folder_id: NULL
|
|
||||||
disk_filename: "test.txt"
|
disk_filename: "test.txt"
|
||||||
size: 4
|
size: 4
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
@ -41,16 +38,14 @@ dmsf_file_revisions_002:
|
|||||||
deleted_by_user_id: NULL
|
deleted_by_user_id: NULL
|
||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by: 1
|
dmsf_workflow_assigned_by: 1
|
||||||
dmsf_workflow_started_by: 1
|
dmsf_workflow_started_by: 1
|
||||||
project_id: 2
|
|
||||||
|
|
||||||
#revision for deleted file on dmsf-enabled project
|
#revision for deleted file on dmsf-enabled project
|
||||||
dmsf_file_revisions_003:
|
dmsf_file_revisions_003:
|
||||||
id: 3
|
id: 3
|
||||||
dmsf_file_id: 3
|
dmsf_file_id: 3
|
||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "deleted.txt"
|
name: "deleted.txt"
|
||||||
dmsf_folder_id: NULL
|
|
||||||
disk_filename: "deleted.txt"
|
disk_filename: "deleted.txt"
|
||||||
size: 4
|
size: 4
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
@ -64,15 +59,13 @@ dmsf_file_revisions_003:
|
|||||||
deleted_by_user_id: 1
|
deleted_by_user_id: 1
|
||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by: 1
|
dmsf_workflow_assigned_by: 1
|
||||||
dmsf_workflow_started_by: 1
|
dmsf_workflow_started_by: 1
|
||||||
project_id: 1
|
|
||||||
|
|
||||||
dmsf_file_revisions_004:
|
dmsf_file_revisions_004:
|
||||||
id: 4
|
id: 4
|
||||||
dmsf_file_id: 4
|
dmsf_file_id: 4
|
||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: 'test.txt'
|
name: 'test.txt'
|
||||||
dmsf_folder_id: NULL
|
|
||||||
disk_filename: 'test.txt'
|
disk_filename: 'test.txt'
|
||||||
size: 4
|
size: 4
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
@ -86,15 +79,13 @@ dmsf_file_revisions_004:
|
|||||||
deleted_by_user_id: NULL
|
deleted_by_user_id: NULL
|
||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by: NULL
|
dmsf_workflow_assigned_by: NULL
|
||||||
dmsf_workflow_started_by: NULL
|
dmsf_workflow_started_by: NULL
|
||||||
project_id: 1
|
|
||||||
|
|
||||||
dmsf_file_revisions_005:
|
dmsf_file_revisions_005:
|
||||||
id: 5
|
id: 5
|
||||||
dmsf_file_id: 1
|
dmsf_file_id: 1
|
||||||
source_dmsf_file_revision_id: NULL
|
source_dmsf_file_revision_id: NULL
|
||||||
name: "test.txt"
|
name: "test.txt"
|
||||||
dmsf_folder_id: NULL
|
|
||||||
disk_filename: "test.txt"
|
disk_filename: "test.txt"
|
||||||
size: 4
|
size: 4
|
||||||
mime_type: text/plain
|
mime_type: text/plain
|
||||||
@ -108,5 +99,4 @@ dmsf_file_revisions_005:
|
|||||||
deleted_by_user_id: NULL
|
deleted_by_user_id: NULL
|
||||||
user_id: 1
|
user_id: 1
|
||||||
dmsf_workflow_assigned_by: NULL
|
dmsf_workflow_assigned_by: NULL
|
||||||
dmsf_workflow_started_by: NULL
|
dmsf_workflow_started_by: NULL
|
||||||
project_id: 1
|
|
||||||
Loading…
x
Reference in New Issue
Block a user