OSDN Git Service

Added some attributes length validations.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Apr 2007 18:44:35 +0000 (18:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Apr 2007 18:44:35 +0000 (18:44 +0000)
Also added some information about attribute length constraints on forms.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@400 e93f8b46-1217-0410-a6f0-8f06a7374b81

13 files changed:
app/models/project.rb
app/models/user.rb
app/views/account/password_recovery.rhtml
app/views/my/account.rhtml
app/views/projects/_form.rhtml
app/views/users/_form.rhtml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fr.yml
lang/it.yml
lang/ja.yml
lang/zh.yml

index 2419e72..60a3767 100644 (file)
@@ -35,8 +35,10 @@ class Project < ActiveRecord::Base
   validates_uniqueness_of :name, :identifier
   validates_associated :custom_values, :on => :update
   validates_associated :repository, :wiki
+  validates_length_of :name, :maximum => 30
   validates_format_of :name, :with => /^[\w\s\'\-]*$/i
-  validates_length_of :identifier, :maximum => 12
+  validates_length_of :description, :maximum => 255
+  validates_length_of :identifier, :in => 3..12
   validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
   
   def identifier=(identifier)
index 869be92..08220be 100644 (file)
@@ -33,9 +33,12 @@ class User < ActiveRecord::Base
   validates_presence_of :login, :firstname, :lastname, :mail
   validates_uniqueness_of :login, :mail        
   # Login must contain lettres, numbers, underscores only
-  validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
   validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i
+  validates_length_of :login, :maximum => 30
+  validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
+  validates_length_of :firstname, :lastname, :maximum => 30
   validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+  validates_length_of :mail, :maximum => 60
   # Password length between 4 and 12
   validates_length_of :password, :in => 4..12, :allow_nil => true
   validates_confirmation_of :password, :allow_nil => true
index 89b1052..c3c451e 100644 (file)
@@ -9,7 +9,8 @@
   <% form_tag({:token => @token.value}, :class => "tabular") do %>
 
   <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
-  <%= password_field_tag 'new_password', nil, :size => 25 %></p>
+  <%= password_field_tag 'new_password', nil, :size => 25 %><br />
+  <em><%= l(:text_length_between, 4, 12) %></em></p>
 
   <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
   <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
index 8a1468c..24f0ef5 100644 (file)
@@ -35,7 +35,8 @@
   <%= password_field_tag 'password', nil, :size => 25 %></p>
 
   <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
-  <%= password_field_tag 'new_password', nil, :size => 25 %></p>
+  <%= password_field_tag 'new_password', nil, :size => 25 %><br />
+  <em><%= l(:text_length_between, 4, 12) %></em></p>
 
   <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
   <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
index 184370b..03a757d 100644 (file)
@@ -2,14 +2,14 @@
 
 <div class="box">
 <!--[form:project]-->
-<p><%= f.text_field :name, :required => true %></p>
+<p><%= f.text_field :name, :required => true %><br /><em><%= l(:text_caracters_maximum, 30) %></em></p>
 
 <% if admin_loggedin? and !@root_projects.empty? %>
     <p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p>
 <% end %>
 
-<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %></p>
-<p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p>
+<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %><br /><em><%= l(:text_caracters_maximum, 255) %></em></p>
+<p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_length_between, 3, 12) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p>
 <p><%= f.text_field :homepage, :size => 40 %></p>
 <p><%= f.check_box :is_public %></p>
 
index 18c8492..43540e6 100644 (file)
@@ -23,7 +23,8 @@
 <p><%= f.select :auth_source_id, [[l(:label_internal), ""]] + @auth_sources.collect { |a| [a.name, a.id] } %></p>
 <% end %>
 <p><label for="password"><%=l(:field_password)%><span class="required"> *</span></label>
-<%= password_field_tag 'password', nil, :size => 25  %></p>
+<%= password_field_tag 'password', nil, :size => 25  %><br />
+<em><%= l(:text_length_between, 4, 12) %></em></p>
 <p><label for="password_confirmation"><%=l(:field_password_confirmation)%><span class="required"> *</span></label>
 <%= password_field_tag 'password_confirmation', nil, :size => 25  %></p>
 </div>
index 39b3ea1..c08b4af 100644 (file)
@@ -397,7 +397,9 @@ text_journal_deleted: gelöscht
 text_tip_task_begin_day: Aufgabe, die an diesem Tag beginnt
 text_tip_task_end_day: Aufgabe, die an diesem Tag beendet
 text_tip_task_begin_end_day: Aufgabe, die an diesem Tag beginnt und beendet
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_caracters_maximum: %d characters maximum.
+text_length_between: Length between %d and %d characters.
 
 default_role_manager: Manager
 default_role_developper: Developer
index 4f0cbe9..4ce8bcb 100644 (file)
@@ -397,7 +397,9 @@ text_journal_deleted: deleted
 text_tip_task_begin_day: task beginning this day
 text_tip_task_end_day: task ending this day
 text_tip_task_begin_end_day: task beginning and ending this day
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_caracters_maximum: %d characters maximum.
+text_length_between: Length between %d and %d characters.
 
 default_role_manager: Manager
 default_role_developper: Developer
index 7b05f37..a201484 100644 (file)
@@ -397,7 +397,9 @@ text_journal_deleted: suprimido
 text_tip_task_begin_day: tarea que comienza este día
 text_tip_task_end_day: tarea que termina este día
 text_tip_task_begin_end_day: tarea que comienza y termina este día
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_caracters_maximum: %d characters maximum.
+text_length_between: Length between %d and %d characters.
 
 default_role_manager: Manager
 default_role_developper: Desarrollador
index 564b5fe..8b52ac5 100644 (file)
@@ -397,7 +397,9 @@ text_journal_deleted: supprimé
 text_tip_task_begin_day: tâche commençant ce jour
 text_tip_task_end_day: tâche finissant ce jour
 text_tip_task_begin_end_day: tâche commençant et finissant ce jour
-text_project_identifier_info: '12 caractères maximum. Lettres (a-z), chiffres (0-9) et tirets autorisés.<br />Un fois sauvegardé, l''identifiant ne pourra plus être modifié.'
+text_project_identifier_info: 'Lettres minuscules (a-z), chiffres et tirets autorisés.<br />Un fois sauvegardé, l''identifiant ne pourra plus être modifié.'
+text_caracters_maximum: %d caractères maximum.
+text_length_between: Longueur comprise entre %d et %d caractères.
 
 default_role_manager: Manager
 default_role_developper: Développeur
index fc2d405..daaed6b 100644 (file)
@@ -397,7 +397,9 @@ text_journal_deleted: deleted
 text_tip_task_begin_day: task beginning this day
 text_tip_task_end_day: task ending this day
 text_tip_task_begin_end_day: task beginning and ending this day
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_caracters_maximum: %d characters maximum.
+text_length_between: Length between %d and %d characters.
 
 default_role_manager: Manager
 default_role_developper: Sviluppatore
index db4335c..bbeb6d4 100644 (file)
@@ -398,7 +398,9 @@ text_journal_deleted: 削除
 text_tip_task_begin_day: この日に開始するタスク
 text_tip_task_end_day: この日に終了するタスク
 text_tip_task_begin_end_day: この日のうちに開始して終了するタスク
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'
+text_caracters_maximum: %d characters maximum.
+text_length_between: Length between %d and %d characters.
 
 default_role_manager: 管理者
 default_role_developper: 開発者
index a0508d3..5ffcb15 100644 (file)
@@ -400,7 +400,9 @@ text_journal_deleted: 已删除
 text_tip_task_begin_day: 开始于此\r
 text_tip_task_end_day: 在此结束\r
 text_tip_task_begin_end_day: 开始并结束于此\r
-text_project_identifier_info: '12 characters maximum. Letters (a-z), numbers (0-9) and dashes allowed.<br />Once saved, the identifier can not be changed.'\r
+text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allowed.<br />Once saved, the identifier can not be changed.'\r
+text_caracters_maximum: %d characters maximum.\r
+text_length_between: Length between %d and %d characters.\r
 \r
 default_role_manager: 管理员\r
 default_role_developper: 开发人员\r