From 8ef06826c31b3042f6720c249199504a49e08c01 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 14 Nov 2010 12:33:14 +0000 Subject: [PATCH] Raised maximum length of project names and identifiers to 255 and 100 respectively (#6446). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4402 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/project.rb | 7 +++++-- app/views/projects/_form.rhtml | 6 +++--- db/migrate/20101114115114_change_projects_name_limit.rb | 9 +++++++++ .../20101114115359_change_projects_identifier_limit.rb | 9 +++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20101114115114_change_projects_name_limit.rb create mode 100644 db/migrate/20101114115359_change_projects_identifier_limit.rb diff --git a/app/models/project.rb b/app/models/project.rb index 43e0ce8d..6eb41cc8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -20,6 +20,9 @@ class Project < ActiveRecord::Base STATUS_ACTIVE = 1 STATUS_ARCHIVED = 9 + # Maximum length for project identifiers + IDENTIFIER_MAX_LENGTH = 100 + # Specific overidden Activities has_many :time_entry_activities has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}" @@ -66,9 +69,9 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier validates_associated :repository, :wiki - validates_length_of :name, :maximum => 30 + validates_length_of :name, :maximum => 255 validates_length_of :homepage, :maximum => 255 - validates_length_of :identifier, :in => 1..20 + validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH # donwcase letters, digits, dashes but not digits only validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? } # reserved words diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index fbc6714c..e8045bf2 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -2,16 +2,16 @@
-

<%= f.text_field :name, :required => true, :maxlength => 30 %>
<%= l(:text_caracters_maximum, 30) %>

+

<%= f.text_field :name, :required => true, :size => 60 %>

<% unless @project.allowed_parents.compact.empty? %>

<%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %>

<% end %>

<%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %>

-

<%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen?, :maxlength => 20 %> +

<%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen? %> <% unless @project.identifier_frozen? %> -
<%= l(:text_length_between, :min => 1, :max => 20) %> <%= l(:text_project_identifier_info) %> +
<%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info) %> <% end %>

<%= f.text_field :homepage, :size => 60 %>

<%= f.check_box :is_public %>

diff --git a/db/migrate/20101114115114_change_projects_name_limit.rb b/db/migrate/20101114115114_change_projects_name_limit.rb new file mode 100644 index 00000000..fabc3c9d --- /dev/null +++ b/db/migrate/20101114115114_change_projects_name_limit.rb @@ -0,0 +1,9 @@ +class ChangeProjectsNameLimit < ActiveRecord::Migration + def self.up + change_column :projects, :name, :string, :limit => nil, :default => '', :null => false + end + + def self.down + change_column :projects, :name, :string, :limit => 30, :default => '', :null => false + end +end diff --git a/db/migrate/20101114115359_change_projects_identifier_limit.rb b/db/migrate/20101114115359_change_projects_identifier_limit.rb new file mode 100644 index 00000000..79426fad --- /dev/null +++ b/db/migrate/20101114115359_change_projects_identifier_limit.rb @@ -0,0 +1,9 @@ +class ChangeProjectsIdentifierLimit < ActiveRecord::Migration + def self.up + change_column :projects, :identifier, :string, :limit => nil + end + + def self.down + change_column :projects, :identifier, :string, :limit => 20 + end +end