stubbed in view code from old danbooru; only janitors can lock a wiki page
This commit is contained in:
@@ -640,8 +640,10 @@ class Post < ActiveRecord::Base
|
||||
if can_be_voted_by?(CurrentUser.user)
|
||||
if score == "up"
|
||||
increment!(:score)
|
||||
increment!(:up_score)
|
||||
elsif score == "down"
|
||||
decrement!(:score)
|
||||
decrement!(:down_score)
|
||||
end
|
||||
|
||||
votes.create(:score => score)
|
||||
|
||||
@@ -2,7 +2,8 @@ class Tag < ActiveRecord::Base
|
||||
attr_accessible :category
|
||||
after_save :update_category_cache
|
||||
has_one :wiki_page, :foreign_key => "name", :primary_key => "title"
|
||||
scope :by_pattern, lambda {|name| where(["name LIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])}
|
||||
scope :name_matches, lambda {|name| where(["name LIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])}
|
||||
search_method :name_matches
|
||||
|
||||
class CategoryMapping
|
||||
Danbooru.config.reverse_tag_category_mapping.each do |value, category|
|
||||
@@ -71,7 +72,7 @@ class Tag < ActiveRecord::Base
|
||||
module NameMethods
|
||||
module ClassMethods
|
||||
def normalize_name(name)
|
||||
name.downcase.tr(" ", "_").gsub(/\A[-~*]+/, "")
|
||||
name.downcase.tr(" ", "_").gsub(/\A[-~]+/, "")
|
||||
end
|
||||
|
||||
def find_or_create_by_name(name, options = {})
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
class UserMailer < ActionMailer::Base
|
||||
default :host => Danbooru.config.server_host, :from => Danbooru.config.contact_email, :content_type => "text/html"
|
||||
|
||||
def password_reset(user, new_password)
|
||||
@user = user
|
||||
@new_password = new_password
|
||||
mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} - Password Reset")
|
||||
end
|
||||
|
||||
def name_reminder(user)
|
||||
@user = user
|
||||
mail(:to => user.email, :subject => "#{Danbooru.config.app_name} - Name Reminder")
|
||||
end
|
||||
|
||||
def deletion(user)
|
||||
@user = user
|
||||
mail(:to => user.email, :subject => "#{}")
|
||||
end
|
||||
|
||||
def dmail_notice(dmail)
|
||||
@dmail = dmail
|
||||
mail(:to => dmail.to.email, :subject => "#{Danbooru.config.app_name} - Message received from #{dmail.from.name}")
|
||||
|
||||
@@ -5,8 +5,10 @@ class WikiPage < ActiveRecord::Base
|
||||
belongs_to :creator, :class_name => "User"
|
||||
validates_uniqueness_of :title, :case_sensitive => false
|
||||
validates_presence_of :body
|
||||
attr_accessible :title, :body
|
||||
validate :validate_locker_is_janitor
|
||||
attr_accessible :title, :body, :is_locked
|
||||
scope :titled, lambda {|title| where(["title = ?", title.downcase.tr(" ", "_")])}
|
||||
scope :recent, order("updated_at DESC").limit(25)
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "title"
|
||||
has_one :artist, :foreign_key => "name", :primary_key => "title"
|
||||
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC"
|
||||
@@ -29,6 +31,13 @@ class WikiPage < ActiveRecord::Base
|
||||
titled(title).select("title, id").first
|
||||
end
|
||||
|
||||
def validate_locker_is_janitor
|
||||
if is_locked_changed? && !CurrentUser.is_janitor?
|
||||
errors.add(:is_locked, "can be modified by janitors only")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def revert_to(version)
|
||||
self.title = version.title
|
||||
self.body = version.body
|
||||
|
||||
Reference in New Issue
Block a user