* finished Issue 30: File upload strange behavior for files with same filename
git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@78 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
parent
a4b1292071
commit
d1a72ce048
@ -126,13 +126,14 @@ class DmsfDetailController < ApplicationController
|
|||||||
end
|
end
|
||||||
@revision.set_workflow(params[:workflow])
|
@revision.set_workflow(params[:workflow])
|
||||||
|
|
||||||
if @revision.save
|
@file.name = @revision.name
|
||||||
|
@file.folder = @revision.folder
|
||||||
|
|
||||||
|
if @revision.save && @file.valid?
|
||||||
unless file_upload.nil?
|
unless file_upload.nil?
|
||||||
@revision.copy_file_content(file_upload)
|
@revision.copy_file_content(file_upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
@file.name = @revision.name
|
|
||||||
@file.folder = @revision.folder
|
|
||||||
if @file.locked?
|
if @file.locked?
|
||||||
DmsfFileLock.file_lock_state(@file, false)
|
DmsfFileLock.file_lock_state(@file, false)
|
||||||
flash[:notice] = l(:notice_file_unlocked) + ", "
|
flash[:notice] = l(:notice_file_unlocked) + ", "
|
||||||
|
|||||||
@ -39,11 +39,12 @@ class DmsfFile < 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)
|
||||||
|
|
||||||
validate_on_create :validates_name_uniqueness
|
validate :validates_name_uniqueness
|
||||||
|
|
||||||
def validates_name_uniqueness
|
def validates_name_uniqueness
|
||||||
errors.add(:name, "has already been taken") if
|
existing_file = DmsfFile.find_file_by_name(self.project, self.folder, self.name)
|
||||||
!DmsfFile.find_file_by_name(self.project, self.folder, self.name).nil?
|
errors.add(:name, "has already been taken") unless
|
||||||
|
existing_file.nil? || existing_file.id == self.id
|
||||||
end
|
end
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{o.name}"},
|
acts_as_event :title => Proc.new {|o| "#{o.name}"},
|
||||||
|
|||||||
@ -47,6 +47,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<%= error_messages_for("file") %>
|
||||||
<%= error_messages_for("revision") %>
|
<%= error_messages_for("revision") %>
|
||||||
|
|
||||||
<% if User.current.allowed_to?(:file_manipulation, @file.project) %>
|
<% if User.current.allowed_to?(:file_manipulation, @file.project) %>
|
||||||
@ -155,7 +156,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% if @revision.valid? %>
|
<% if @revision.valid? && @file.valid? %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
jQuery("#newRevisionFormContentToggle").text("[+]");
|
jQuery("#newRevisionFormContentToggle").text("[+]");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user