|
|
@ -37,6 +37,7 @@ class WikiPage < ActiveRecord::Base
|
|
|
|
belongs_to :user, :with_deleted => true
|
|
|
|
belongs_to :user, :with_deleted => true
|
|
|
|
|
|
|
|
|
|
|
|
# Valicacao
|
|
|
|
# Valicacao
|
|
|
|
|
|
|
|
validates_presence_of :front_page
|
|
|
|
validates_presence_of :description
|
|
|
|
validates_presence_of :description
|
|
|
|
validates_presence_of :title
|
|
|
|
validates_presence_of :title
|
|
|
|
validates_presence_of :content
|
|
|
|
validates_presence_of :content
|
|
|
@ -44,16 +45,21 @@ class WikiPage < ActiveRecord::Base
|
|
|
|
validates_uniqueness_of :canonical_title, :scope => :course_id
|
|
|
|
validates_uniqueness_of :canonical_title, :scope => :course_id
|
|
|
|
validates_format_of :title, :with => /^[^0-9]/
|
|
|
|
validates_format_of :title, :with => /^[^0-9]/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_validation :set_canonical_title
|
|
|
|
|
|
|
|
before_save :set_position
|
|
|
|
|
|
|
|
|
|
|
|
# acts_as_paranoid_versioned
|
|
|
|
# acts_as_paranoid_versioned
|
|
|
|
self.versioned_class.class_eval do
|
|
|
|
self.versioned_class.class_eval do
|
|
|
|
def self.delete_all(conditions = nil); return; end
|
|
|
|
def self.delete_all(conditions = nil)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def before_validation
|
|
|
|
def set_canonical_title
|
|
|
|
self.canonical_title = self.title.pretty_url
|
|
|
|
self.canonical_title = self.title.pretty_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def before_save
|
|
|
|
def set_position
|
|
|
|
if !self.front_page
|
|
|
|
if !self.front_page
|
|
|
|
self.remove_from_list
|
|
|
|
self.remove_from_list
|
|
|
|
elsif self.position.nil?
|
|
|
|
elsif self.position.nil?
|
|
|
@ -74,7 +80,7 @@ class WikiPage < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.find_front_page
|
|
|
|
def self.find_front_page
|
|
|
|
WikiPage.find(:all, :conditions => [ "front_page = ?", true ])
|
|
|
|
WikiPage.all(:conditions => ["front_page = ?", true])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def WikiPage.diff(from, to)
|
|
|
|
def WikiPage.diff(from, to)
|
|
|
|