Filename can't be blank by a new revision
This commit is contained in:
parent
f6fcb98920
commit
dd5cf37a5c
@ -155,13 +155,11 @@ class DmsfFilesController < ApplicationController
|
||||
|
||||
@file.name = revision.name
|
||||
|
||||
if revision.valid? && @file.valid?
|
||||
revision.save!
|
||||
if revision.save
|
||||
revision.assign_workflow(params[:dmsf_workflow_id])
|
||||
if file_upload
|
||||
revision.copy_file_content(file_upload)
|
||||
end
|
||||
|
||||
if @file.locked? && !@file.locks.empty?
|
||||
begin
|
||||
@file.unlock!
|
||||
@ -170,26 +168,30 @@ class DmsfFilesController < ApplicationController
|
||||
logger.error "Cannot unlock the file: #{e.message}"
|
||||
end
|
||||
end
|
||||
@file.save!
|
||||
@file.set_last_revision revision
|
||||
|
||||
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
|
||||
log_activity('new revision')
|
||||
begin
|
||||
recipients = DmsfMailer.get_notify_users(@project, [@file])
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_updated(u, @project, [@file]).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
flash[:warning] = l(:warning_email_notifications, :to => to)
|
||||
if @file.save
|
||||
@file.set_last_revision revision
|
||||
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
|
||||
log_activity('new revision')
|
||||
begin
|
||||
recipients = DmsfMailer.get_notify_users(@project, [@file])
|
||||
recipients.each do |u|
|
||||
DmsfMailer.files_updated(u, @project, [@file]).deliver
|
||||
end
|
||||
if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1'
|
||||
unless recipients.empty?
|
||||
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
|
||||
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
|
||||
flash[:warning] = l(:warning_email_notifications, :to => to)
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
logger.error "Could not send email notifications: #{e.message}"
|
||||
end
|
||||
rescue Exception => e
|
||||
logger.error "Could not send email notifications: #{e.message}"
|
||||
else
|
||||
flash[:error] = @file.errors.full_messages.join(', ')
|
||||
end
|
||||
else
|
||||
flash[:error] = revision.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,9 +28,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
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
|
||||
accepts_nested_attributes_for :access, :dmsf_workflow_step_assignment, :file, :user
|
||||
|
||||
attr_accessible :file, :title, :name, :description, :comment
|
||||
accepts_nested_attributes_for :access, :dmsf_workflow_step_assignment, :file, :user
|
||||
|
||||
# Returns a list of revisions that are not deleted here, or deleted at parent level either
|
||||
scope :visible, -> { where(deleted: false) }
|
||||
@ -53,7 +51,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id").
|
||||
where("#{DmsfFile.table_name}.deleted = :false", {:false => false})
|
||||
|
||||
validates :title, :name, :presence => true
|
||||
validates :title, :presence => true
|
||||
validates_format_of :name, :with => DmsfFolder.invalid_characters,
|
||||
:message => l(:error_contains_invalid_character)
|
||||
|
||||
|
||||
29
db/migrate/201500910153701_title_not_null.rb
Normal file
29
db/migrate/201500910153701_title_not_null.rb
Normal file
@ -0,0 +1,29 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-15 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 TitleNotNull < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :dmsf_file_revisions, :title, :string, :null => false
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :dmsf_file_revisions, :title, :string, :null => true
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user