##// END OF EJS Templates
Remove the limitation on characters that can be used in custom_field, issue_status, role, tracker, user names (#5152)....
Jean-Philippe Lang -
r4479:44ffc5a3365f
parent child
Show More
@@ -23,7 +23,6 class CustomField < ActiveRecord::Base
23 validates_presence_of :name, :field_format
23 validates_presence_of :name, :field_format
24 validates_uniqueness_of :name, :scope => :type
24 validates_uniqueness_of :name, :scope => :type
25 validates_length_of :name, :maximum => 30
25 validates_length_of :name, :maximum => 30
26 validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i
27 validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
26 validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
28
27
29 def initialize(attributes = nil)
28 def initialize(attributes = nil)
@@ -25,7 +25,6 class IssueStatus < ActiveRecord::Base
25 validates_presence_of :name
25 validates_presence_of :name
26 validates_uniqueness_of :name
26 validates_uniqueness_of :name
27 validates_length_of :name, :maximum => 30
27 validates_length_of :name, :maximum => 30
28 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
29 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
28 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
30
29
31 def after_save
30 def after_save
@@ -43,7 +43,6 class Role < ActiveRecord::Base
43 validates_presence_of :name
43 validates_presence_of :name
44 validates_uniqueness_of :name
44 validates_uniqueness_of :name
45 validates_length_of :name, :maximum => 30
45 validates_length_of :name, :maximum => 30
46 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
47
46
48 def permissions
47 def permissions
49 read_attribute(:permissions) || []
48 read_attribute(:permissions) || []
@@ -31,7 +31,6 class Tracker < ActiveRecord::Base
31 validates_presence_of :name
31 validates_presence_of :name
32 validates_uniqueness_of :name
32 validates_uniqueness_of :name
33 validates_length_of :name, :maximum => 30
33 validates_length_of :name, :maximum => 30
34 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
35
34
36 def to_s; name end
35 def to_s; name end
37
36
@@ -68,7 +68,6 class User < Principal
68 # Login must contain lettres, numbers, underscores only
68 # Login must contain lettres, numbers, underscores only
69 validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
69 validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
70 validates_length_of :login, :maximum => 30
70 validates_length_of :login, :maximum => 30
71 validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-\.]*$/i
72 validates_length_of :firstname, :lastname, :maximum => 30
71 validates_length_of :firstname, :lastname, :maximum => 30
73 validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
72 validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
74 validates_length_of :mail, :maximum => 60, :allow_nil => true
73 validates_length_of :mail, :maximum => 60, :allow_nil => true
@@ -88,13 +88,11 task :migrate_from_mantis => :environment do
88
88
89 def firstname
89 def firstname
90 @firstname = realname.blank? ? username : realname.split.first[0..29]
90 @firstname = realname.blank? ? username : realname.split.first[0..29]
91 @firstname.gsub!(/[^\w\s\'\-]/i, '')
92 @firstname
91 @firstname
93 end
92 end
94
93
95 def lastname
94 def lastname
96 @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29]
95 @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29]
97 @lastname.gsub!(/[^\w\s\'\-]/i, '')
98 @lastname = '-' if @lastname.blank?
96 @lastname = '-' if @lastname.blank?
99 @lastname
97 @lastname
100 end
98 end
@@ -224,7 +222,7 task :migrate_from_mantis => :environment do
224 end
222 end
225
223
226 def name
224 def name
227 read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-')
225 read_attribute(:name)[0..29]
228 end
226 end
229 end
227 end
230
228
@@ -246,8 +246,8 namespace :redmine do
246 ln = ($2 || '-').strip
246 ln = ($2 || '-').strip
247
247
248 u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'),
248 u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'),
249 :firstname => fn[0, limit_for(User, 'firstname')].gsub(/[^\w\s\'\-]/i, '-'),
249 :firstname => fn[0, limit_for(User, 'firstname')],
250 :lastname => ln[0, limit_for(User, 'lastname')].gsub(/[^\w\s\'\-]/i, '-')
250 :lastname => ln[0, limit_for(User, 'lastname')]
251
251
252 u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-')
252 u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-')
253 u.password = 'trac'
253 u.password = 'trac'
General Comments 0
You need to be logged in to leave comments. Login now