Fixed 10211 Wiki names can't have periods in them.

Same validations as WikiPage model now applied to wiki start page.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@463 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-04-22 09:50:16 +00:00
parent 3d685f7bec
commit 8d7de50ca8
11 changed files with 12 additions and 3 deletions

View File

@ -20,6 +20,7 @@ class Wiki < ActiveRecord::Base
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy has_many :pages, :class_name => 'WikiPage', :dependent => :destroy
validates_presence_of :start_page validates_presence_of :start_page
validates_format_of :start_page, :with => /^[^,\.\/\?\;\|]*$/
# find the page with the given title # find the page with the given title
# if page doesn't exist, return a new page # if page doesn't exist, return a new page
@ -36,7 +37,7 @@ class Wiki < ActiveRecord::Base
# turn a string into a valid page title # turn a string into a valid page title
def self.titleize(title) def self.titleize(title)
# replace spaces with _ and remove unwanted caracters # replace spaces with _ and remove unwanted caracters
title = title.gsub(/\s+/, '_').delete(',;|') if title title = title.gsub(/\s+/, '_').delete(',./?;|') if title
# upcase the first letter # upcase the first letter
title = title[0..0].upcase + title[1..-1] if title title = title[0..0].upcase + title[1..-1] if title
title title

View File

@ -20,7 +20,7 @@ class WikiPage < ActiveRecord::Base
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
validates_presence_of :title validates_presence_of :title
validates_format_of :title, :with => /^[^,\s]*$/ validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/
validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
validates_associated :content validates_associated :content

View File

@ -44,7 +44,7 @@
<%= hidden_field_tag "wiki_enabled", 0 %> <%= hidden_field_tag "wiki_enabled", 0 %>
<div id="wiki"> <div id="wiki">
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %> <% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %>
<p><%= wiki.text_field :start_page, :size => 60, :required => true %></p> <p><%= wiki.text_field :start_page, :size => 60, :required => true %><br /><em><%= l(:text_unallowed_characters) %>: , . / ? ; |</em></p>
<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") + <% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") +
# auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } }) # auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } })
%> %>

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo
text_caracters_maximum: %d characters maximum. text_caracters_maximum: %d characters maximum.
text_length_between: Length between %d and %d characters. text_length_between: Length between %d and %d characters.
text_tracker_no_workflow: No workflow defined for this tracker text_tracker_no_workflow: No workflow defined for this tracker
text_unallowed_characters: Unallowed characters
default_role_manager: Manager default_role_manager: Manager
default_role_developper: Developer default_role_developper: Developer

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo
text_caracters_maximum: %d characters maximum. text_caracters_maximum: %d characters maximum.
text_length_between: Length between %d and %d characters. text_length_between: Length between %d and %d characters.
text_tracker_no_workflow: No workflow defined for this tracker text_tracker_no_workflow: No workflow defined for this tracker
text_unallowed_characters: Unallowed characters
default_role_manager: Manager default_role_manager: Manager
default_role_developper: Developer default_role_developper: Developer

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo
text_caracters_maximum: %d characters maximum. text_caracters_maximum: %d characters maximum.
text_length_between: Length between %d and %d characters. text_length_between: Length between %d and %d characters.
text_tracker_no_workflow: No workflow defined for this tracker text_tracker_no_workflow: No workflow defined for this tracker
text_unallowed_characters: Unallowed characters
default_role_manager: Manager default_role_manager: Manager
default_role_developper: Desarrollador default_role_developper: Desarrollador

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Lettres minuscules (a-z), chiffres et tirets auto
text_caracters_maximum: %d caractères maximum. text_caracters_maximum: %d caractères maximum.
text_length_between: Longueur comprise entre %d et %d caractères. text_length_between: Longueur comprise entre %d et %d caractères.
text_tracker_no_workflow: Aucun worflow n'est défini pour ce tracker text_tracker_no_workflow: Aucun worflow n'est défini pour ce tracker
text_unallowed_characters: Caractères non autorisés
default_role_manager: Manager default_role_manager: Manager
default_role_developper: Développeur default_role_developper: Développeur

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo
text_caracters_maximum: %d characters maximum. text_caracters_maximum: %d characters maximum.
text_length_between: Length between %d and %d characters. text_length_between: Length between %d and %d characters.
text_tracker_no_workflow: No workflow defined for this tracker text_tracker_no_workflow: No workflow defined for this tracker
text_unallowed_characters: Unallowed characters
default_role_manager: Manager default_role_manager: Manager
default_role_developper: Sviluppatore default_role_developper: Sviluppatore

View File

@ -408,6 +408,7 @@ text_project_identifier_info: '英小文字(a-z)と数字とダッシュ(-)が
text_caracters_maximum: 最大 %d 文字です。 text_caracters_maximum: 最大 %d 文字です。
text_length_between: 長さは %d から %d 文字までです。 text_length_between: 長さは %d から %d 文字までです。
text_tracker_no_workflow: このトラッカーにワークフローが定義されていません text_tracker_no_workflow: このトラッカーにワークフローが定義されていません
text_unallowed_characters: Unallowed characters
default_role_manager: 管理者 default_role_manager: 管理者
default_role_developper: 開発者 default_role_developper: 開発者

View File

@ -407,6 +407,7 @@ text_project_identifier_info: 'Letras minusculas (a-z), numeros e tracos permiti
text_caracters_maximum: %d maximo de caracteres text_caracters_maximum: %d maximo de caracteres
text_length_between: Tamanho entre %d e %d caracteres. text_length_between: Tamanho entre %d e %d caracteres.
text_tracker_no_workflow: Sem workflow definido para este tipo. text_tracker_no_workflow: Sem workflow definido para este tipo.
text_unallowed_characters: Unallowed characters
default_role_manager: Analista de Negocio ou Gerente de Projeto default_role_manager: Analista de Negocio ou Gerente de Projeto
default_role_developper: Desenvolvedor default_role_developper: Desenvolvedor

View File

@ -410,6 +410,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo
text_caracters_maximum: %d characters maximum. text_caracters_maximum: %d characters maximum.
text_length_between: Length between %d and %d characters. text_length_between: Length between %d and %d characters.
text_tracker_no_workflow: No workflow defined for this tracker text_tracker_no_workflow: No workflow defined for this tracker
text_unallowed_characters: Unallowed characters
default_role_manager: 管理员 default_role_manager: 管理员
default_role_developper: 开发人员 default_role_developper: 开发人员