This commit is contained in:
r888888888
2013-09-12 15:20:20 -07:00
parent 19d886af01
commit e127e8b6f2
2 changed files with 28 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ class WikiPage < ActiveRecord::Base
validates_uniqueness_of :title, :case_sensitive => false
validates_presence_of :title
validate :validate_locker_is_janitor
validate :validate_not_locked
attr_accessible :title, :body, :is_locked
has_one :tag, :foreign_key => "name", :primary_key => "title"
has_one :artist, :foreign_key => "name", :primary_key => "title", :conditions => {:is_active => true}
@@ -101,6 +102,13 @@ class WikiPage < ActiveRecord::Base
end
end
def validate_not_locked
if is_locked? && !CurrentUser.is_janitor?
errors.add(:is_locked, "and cannot be updated")
return false
end
end
def revert_to(version)
self.title = version.title
self.body = version.body