From a8eb0f8cc1fd882a3b932fd7956ab19a84ff7d3a Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 23 Mar 2017 13:39:21 +0100 Subject: [PATCH] Description length limit --- app/models/dmsf_folder.rb | 1 + .../20170323131231_dmsf_description_limit.rb | 31 +++++++++++++++++++ lib/redmine_dmsf/patches/project_patch.rb | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 db/migrate/20170323131231_dmsf_description_limit.rb diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 50cc8489..a995c610 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -72,6 +72,7 @@ class DmsfFolder < ActiveRecord::Base validates_format_of :title, :with => INVALID_CHARACTERS, :message => l(:error_contains_invalid_character) validate :check_cycle + validates_length_of :description, :maximum => 65535 before_create :default_values def default_values diff --git a/db/migrate/20170323131231_dmsf_description_limit.rb b/db/migrate/20170323131231_dmsf_description_limit.rb new file mode 100644 index 00000000..ea281f40 --- /dev/null +++ b/db/migrate/20170323131231_dmsf_description_limit.rb @@ -0,0 +1,31 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-17 Karel Pičman +# +# 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 DmsfDescriptionLimit < ActiveRecord::Migration + def up + change_column :projects, :dmsf_description, :text, :null => true, :limit => 65535 + change_column :dmsf_folders, :description, :text,:null => true, :limit => 65535 + end + + def down + change_column :projects, :dmsf_description, :text + change_column :dmsf_folders, :description, :text + end +end diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 3085c9cd..c414835a 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -46,6 +46,8 @@ module RedmineDmsf :class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy before_save :set_default_dmsf_notification + + validates_length_of :dmsf_description, :maximum => 65535 end end