comparison app/models/wiki_page.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
38 :project_key => "#{Wiki.table_name}.project_id" 38 :project_key => "#{Wiki.table_name}.project_id"
39 39
40 attr_accessor :redirect_existing_links 40 attr_accessor :redirect_existing_links
41 41
42 validates_presence_of :title 42 validates_presence_of :title
43 validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/ 43 validates_format_of :title, :with => /\A[^,\.\/\?\;\|\s]*\z/
44 validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false 44 validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
45 validates_associated :content 45 validates_associated :content
46 46
47 validate :validate_parent_title 47 validate :validate_parent_title
48 before_destroy :remove_redirects 48 before_destroy :remove_redirects
49 before_save :handle_redirects 49 before_save :handle_redirects
50 50
51 # eager load information about last updates, without loading text 51 # eager load information about last updates, without loading text
52 scope :with_updated_on, { 52 scope :with_updated_on, lambda {
53 :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on, #{WikiContent.table_name}.version", 53 select("#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on, #{WikiContent.table_name}.version").
54 :joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id" 54 joins("LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id")
55 } 55 }
56 56
57 # Wiki pages that are protected by default 57 # Wiki pages that are protected by default
58 DEFAULT_PROTECTED_PAGES = %w(sidebar) 58 DEFAULT_PROTECTED_PAGES = %w(sidebar)
59 59