Minor fixes
This commit is contained in:
@@ -87,6 +87,10 @@ class Course < ActiveRecord::Base
|
||||
period == App.current_period ? short_name : id.to_s
|
||||
end
|
||||
|
||||
def self.pluck_periods
|
||||
Course.uniq.pluck(:period).reject!(&:blank?).sort.reverse
|
||||
end
|
||||
|
||||
def self.from_param(param)
|
||||
param.is_numeric? ? Course.find(param) : Course.find_by_short_name!(param)
|
||||
end
|
||||
|
||||
@@ -44,6 +44,8 @@ class WikiPage < ActiveRecord::Base
|
||||
validates_uniqueness_of :title, scope: :course_id
|
||||
validates_uniqueness_of :canonical_title, scope: :course_id
|
||||
validates_format_of :title, with: /^[^0-9]/
|
||||
validate :check_wiki_syntax
|
||||
|
||||
|
||||
before_validation :set_canonical_title
|
||||
before_save :set_position
|
||||
@@ -68,11 +70,10 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def validate
|
||||
def check_wiki_syntax
|
||||
content.format_wiki
|
||||
rescue
|
||||
errors.add("content", "possui erro de sintaxe: " +
|
||||
$ERROR_INFO.to_s.html_escape)
|
||||
errors.add("content", "possui erro de sintaxe")
|
||||
end
|
||||
|
||||
def to_param
|
||||
|
||||
Reference in New Issue
Block a user