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