Minor fixes

This commit is contained in:
2015-09-05 11:29:13 -04:00
parent 60fea13794
commit 1cf1c28d3a
30 changed files with 154 additions and 1184 deletions

View File

@@ -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

View File

@@ -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