fixes #2133
This commit is contained in:
@@ -120,9 +120,9 @@ protected
|
||||
|
||||
def secure_cookies_check
|
||||
if request.ssl?
|
||||
Danbooru::Application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => true
|
||||
Rails.application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => true
|
||||
else
|
||||
Danbooru::Application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => false
|
||||
Rails.application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -106,7 +106,7 @@ class PostQueryBuilder
|
||||
q = Tag.parse_query(query_string)
|
||||
end
|
||||
|
||||
relation = Post.scoped
|
||||
relation = Post.where("true")
|
||||
|
||||
if q[:tag_count].to_i > Danbooru.config.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module PostSets
|
||||
class Favorite < Base
|
||||
class Favorite < PostSets::Base
|
||||
attr_reader :user, :page, :favorites, :params
|
||||
|
||||
def initialize(user_id, page = 1, params = {})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module PostSets
|
||||
class Note < Post
|
||||
class Note < PostSets::Post
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module PostSets
|
||||
class Pool < Base
|
||||
class Pool < PostSets::Base
|
||||
module ActiveRecordExtension
|
||||
attr_accessor :total_pages, :current_page
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module PostSets
|
||||
class Popular < Base
|
||||
class Popular < PostSets::Base
|
||||
attr_reader :date, :scale
|
||||
|
||||
def initialize(date, scale)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module PostSets
|
||||
class Post < Base
|
||||
class Post < PostSets::Base
|
||||
attr_reader :tag_array, :page, :per_page, :raw
|
||||
|
||||
def initialize(tags, page = 1, per_page = nil, raw = false)
|
||||
|
||||
@@ -3,6 +3,7 @@ class Advertisement < ActiveRecord::Base
|
||||
has_many :hits, :class_name => "AdvertisementHit"
|
||||
after_create :copy_to_servers
|
||||
after_destroy :delete_from_servers
|
||||
attr_accessible :ad_type, :width, :height, :referral_url, :status, :file_name, :is_work_safe, :hit_count
|
||||
|
||||
def copy_to_servers
|
||||
RemoteFileManager.new(image_path).distribute
|
||||
|
||||
@@ -2,4 +2,5 @@ class AdvertisementHit < ActiveRecord::Base
|
||||
belongs_to :advertisement
|
||||
|
||||
scope :between, lambda {|start_date, end_date| where("created_at BETWEEN ? AND ?", start_date, end_date)}
|
||||
attr_accessible :ip_addr
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ require 'base64'
|
||||
require 'digest/md5'
|
||||
|
||||
class AmazonBackup < ActiveRecord::Base
|
||||
attr_accessible :last_id
|
||||
|
||||
def self.last_id
|
||||
first.last_id
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Artist < ActiveRecord::Base
|
||||
belongs_to :creator, :class_name => "User"
|
||||
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
|
||||
has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl"
|
||||
has_many :versions, :order => "artist_versions.id ASC", :class_name => "ArtistVersion"
|
||||
has_many :versions, lambda {order("artist_versions.id ASC")}, :class_name => "ArtistVersion"
|
||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "name"
|
||||
@@ -33,7 +33,7 @@ class Artist < ActiveRecord::Base
|
||||
break if url =~ /pixiv\.net\/(?:img\/)?$/
|
||||
end
|
||||
|
||||
artists.uniq_by {|x| x.name}.slice(0, 20)
|
||||
artists.inject({}) {|h, x| h[x.name] = x; h}.values.slice(0, 20)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -322,7 +322,7 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
case params[:name]
|
||||
|
||||
@@ -2,7 +2,7 @@ class ArtistCommentary < ActiveRecord::Base
|
||||
attr_accessible :post_id, :original_description, :original_title, :translated_description, :translated_title
|
||||
validates_uniqueness_of :post_id
|
||||
belongs_to :post
|
||||
has_many :versions, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id, :order => "artist_commentary_versions.id ASC"
|
||||
has_many :versions, lambda {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id
|
||||
after_save :create_version
|
||||
|
||||
module SearchMethods
|
||||
@@ -17,7 +17,7 @@ class ArtistCommentary < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:text_matches].present?
|
||||
|
||||
@@ -2,6 +2,7 @@ class ArtistCommentaryVersion < ActiveRecord::Base
|
||||
before_validation :initialize_updater
|
||||
belongs_to :updater, :class_name => "User"
|
||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
||||
attr_accessible :post_id, :original_title, :original_description, :translated_title, :translated_description
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
|
||||
@@ -2,6 +2,7 @@ class ArtistUrl < ActiveRecord::Base
|
||||
before_save :normalize
|
||||
validates_presence_of :url
|
||||
belongs_to :artist
|
||||
attr_accessible :url, :artist_id, :normalized_url
|
||||
|
||||
def self.normalize(url)
|
||||
if url.nil?
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ArtistVersion < ActiveRecord::Base
|
||||
belongs_to :updater, :class_name => "User"
|
||||
belongs_to :artist
|
||||
attr_accessible :artist_id, :name, :is_active, :other_names, :group_name, :url_string, :is_banned, :updater_id, :updater_ip_addr
|
||||
|
||||
module SearchMethods
|
||||
def for_user(user_id)
|
||||
@@ -12,7 +13,7 @@ class ArtistVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name].present?
|
||||
|
||||
@@ -15,7 +15,7 @@ class Ban < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:banner_name]
|
||||
|
||||
@@ -45,7 +45,7 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:body_matches].present?
|
||||
@@ -139,9 +139,9 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_last_commented_at_on_create
|
||||
Post.update_all(["last_commented_at = ?", created_at], ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_commented_at => created_at)
|
||||
if Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post?
|
||||
Post.update_all(["last_comment_bumped_at = ?", created_at], ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_comment_bumped_at => created_at)
|
||||
end
|
||||
true
|
||||
end
|
||||
@@ -149,16 +149,16 @@ class Comment < ActiveRecord::Base
|
||||
def update_last_commented_at_on_destroy
|
||||
other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order("id DESC")
|
||||
if other_comments.count == 0
|
||||
Post.update_all("last_commented_at = NULL", ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_commented_at => nil)
|
||||
else
|
||||
Post.update_all(["last_commented_at = ?", other_comments.first.created_at], ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_commented_at => other_comments.first.created_at)
|
||||
end
|
||||
|
||||
other_comments = other_comments.where("do_not_bump_post = FALSE")
|
||||
if other_comments.count == 0
|
||||
Post.update_all("last_comment_bumped_at = NULL", ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_comment_bumped_at => nil)
|
||||
else
|
||||
Post.update_all(["last_comment_bumped_at = ?", other_comments.first.created_at], ["id = ?", post_id])
|
||||
Post.where(:id => post_id).update_all(:last_comment_bumped_at => other_comments.first.created_at)
|
||||
end
|
||||
|
||||
true
|
||||
|
||||
@@ -9,13 +9,14 @@ class CommentVote < ActiveRecord::Base
|
||||
validate :validate_user_can_vote
|
||||
validate :validate_comment_can_be_down_voted
|
||||
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
||||
attr_accessible :comment_id, :user_id, :score
|
||||
|
||||
def self.prune!
|
||||
destroy_all("created_at < ?", 14.days.ago)
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:comment_id]
|
||||
|
||||
@@ -124,7 +124,7 @@ class Dmail < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:message_matches].present?
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Favorite < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
scope :for_user, lambda {|user_id| where("user_id % 100 = #{user_id.to_i % 100} and user_id = #{user_id.to_i}")}
|
||||
attr_accessible :user_id, :post_id
|
||||
|
||||
# this is necessary because there's no trigger for deleting favorites
|
||||
def self.destroy_all(hash)
|
||||
@@ -14,11 +15,11 @@ class Favorite < ActiveRecord::Base
|
||||
def self.add(post, user)
|
||||
Favorite.transaction do
|
||||
return if Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post.id).exists?
|
||||
Favorite.create(:user_id => user.id, :post_id => post.id)
|
||||
Post.update_all("fav_count = fav_count + 1", {:id => post.id})
|
||||
Post.update_all("score = score + 1", {:id => post.id}) if user.is_gold?
|
||||
Favorite.create!(:user_id => user.id, :post_id => post.id)
|
||||
Post.where(:id => post.id).update_all("fav_count = fav_count + 1")
|
||||
Post.where(:id => post.id).update_all("score = score + 1") if user.is_gold?
|
||||
post.append_user_to_fav_string(user.id)
|
||||
User.update_all("favorite_count = favorite_count + 1", {:id => user.id})
|
||||
User.where(:id => user.id).update_all("favorite_count = favorite_count + 1")
|
||||
user.favorite_count += 1
|
||||
# post.fav_count += 1 # this is handled in Post#clean_fav_string!
|
||||
post.score += 1 if user.is_gold?
|
||||
@@ -29,10 +30,10 @@ class Favorite < ActiveRecord::Base
|
||||
Favorite.transaction do
|
||||
return unless Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post.id).exists?
|
||||
Favorite.destroy_all(:user_id => user.id, :post_id => post.id)
|
||||
Post.update_all("fav_count = fav_count - 1", {:id => post.id})
|
||||
Post.update_all("score = score - 1", {:id => post.id}) if user.is_gold?
|
||||
Post.where(:id => post.id).update_all("fav_count = fav_count - 1")
|
||||
Post.where(:id => post.id).update_all("Score = score - 1") if user.is_gold?
|
||||
post.delete_user_from_fav_string(user.id)
|
||||
User.update_all("favorite_count = favorite_count - 1", {:id => user.id})
|
||||
User.where(:id => user.id).update_all("favorite_count = favorite_count - 1")
|
||||
user.favorite_count -= 1
|
||||
post.fav_count -= 1
|
||||
post.score -= 1 if user.is_gold?
|
||||
|
||||
@@ -46,7 +46,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
@@ -109,7 +109,7 @@ class ForumPost < ActiveRecord::Base
|
||||
def update_topic_updated_at_on_create
|
||||
if topic
|
||||
# need to do this to bypass the topic's original post from getting touched
|
||||
ForumTopic.update_all(["updater_id = ?, response_count = response_count + 1, updated_at = ?", CurrentUser.id, Time.now], {:id => topic.id})
|
||||
ForumTopic.where(:id => topic.id).update_all(["updater_id = ?, response_count = response_count + 1, updated_at = ?", CurrentUser.id, Time.now])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -132,9 +132,9 @@ class ForumPost < ActiveRecord::Base
|
||||
def update_topic_updated_at_on_destroy
|
||||
max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).order("updated_at desc").first
|
||||
if max
|
||||
ForumTopic.update_all(["response_count = response_count - 1, updated_at = ?, updater_id = ?", max.updated_at, max.updater_id], {:id => topic.id})
|
||||
ForumTopic.where(:id => topic.id).update_all(["response_count = response_count - 1, updated_at = ?, updater_id = ?", max.updated_at, max.updater_id])
|
||||
else
|
||||
ForumTopic.update_all(["response_count = response_count - 1"], {:id => topic.id})
|
||||
ForumTopic.where(:id => topic.id).update_all("response_count = response_count - 1")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ class ForumTopic < ActiveRecord::Base
|
||||
attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:janitor, :admin, :moderator]
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy
|
||||
has_one :original_post, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id"
|
||||
has_many :posts, lambda {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id", :dependent => :destroy
|
||||
has_one :original_post, lambda {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id"
|
||||
before_validation :initialize_creator, :on => :create
|
||||
before_validation :initialize_updater
|
||||
before_validation :initialize_is_deleted, :on => :create
|
||||
@@ -55,7 +55,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:title_matches].present?
|
||||
@@ -133,7 +133,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_last_forum_read_at(read_forum_topic_ids)
|
||||
query = ForumTopic.scoped
|
||||
query = ForumTopic.where("true")
|
||||
if CurrentUser.user.last_forum_read_at.present?
|
||||
query = query.where("updated_at >= ?", CurrentUser.last_forum_read_at)
|
||||
end
|
||||
@@ -150,7 +150,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def merge(topic)
|
||||
ForumPost.update_all({:topic_id => id}, :id => topic.posts.map(&:id))
|
||||
ForumPost.where(:id => topic.posts.map(&:id)).update_all(:topic_id => id)
|
||||
update_attribute(:is_deleted, true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,13 +5,14 @@ class IpBan < ActiveRecord::Base
|
||||
validates_presence_of :reason, :creator, :ip_addr
|
||||
validates_format_of :ip_addr, :with => IP_ADDR_REGEX
|
||||
validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX}
|
||||
attr_accessible :ip_addr, :reason
|
||||
|
||||
def self.is_banned?(ip_addr)
|
||||
exists?(["ip_addr = ?", ip_addr])
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:ip_addr].present?
|
||||
@@ -36,7 +37,7 @@ class IpBan < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.count_by_ip_addr(table, user_ids, user_id_field = "user_id", ip_addr_field = "ip_addr")
|
||||
select_all_sql("SELECT #{ip_addr_field}, count(*) FROM #{table} WHERE #{user_id_field} IN (?) GROUP BY #{ip_addr_field} ORDER BY count(*) DESC", user_ids)
|
||||
select_all_sql("SELECT #{ip_addr_field}, count(*) FROM #{table} WHERE #{user_id_field} IN (?) GROUP BY #{ip_addr_field} ORDER BY count(*) DESC", user_ids).to_hash
|
||||
end
|
||||
|
||||
def initialize_creator
|
||||
|
||||
@@ -5,9 +5,10 @@ class JanitorTrial < ActiveRecord::Base
|
||||
after_create :promote_user
|
||||
validates_presence_of :user
|
||||
before_validation :initialize_creator
|
||||
attr_accessible :user_id
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:user_name]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class KeyValue < ActiveRecord::Base
|
||||
validates_uniqueness_of :key
|
||||
attr_accessible :key, :value
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ModAction < ActiveRecord::Base
|
||||
belongs_to :creator, :class_name => "User"
|
||||
before_validation :initialize_creator, :on => :create
|
||||
attr_accessible :description
|
||||
|
||||
def self.search(params = {})
|
||||
q = scoped
|
||||
|
||||
@@ -4,6 +4,7 @@ class NewsUpdate < ActiveRecord::Base
|
||||
scope :recent, lambda {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)}
|
||||
before_validation :initialize_creator, :on => :create
|
||||
before_validation :initialize_updater
|
||||
attr_accessible :message
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.id
|
||||
|
||||
@@ -3,17 +3,17 @@ class Note < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
has_many :versions, lambda {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy
|
||||
before_validation :initialize_creator, :on => :create
|
||||
before_validation :initialize_updater
|
||||
before_validation :blank_body
|
||||
validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height
|
||||
validate :post_must_exist
|
||||
validate :note_within_image, :message => "must be inside the image"
|
||||
has_many :versions, :class_name => "NoteVersion", :dependent => :destroy, :order => "note_versions.id ASC"
|
||||
after_save :update_post
|
||||
after_save :create_version
|
||||
validate :post_must_not_be_note_locked
|
||||
attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :html_id
|
||||
attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :post, :html_id
|
||||
|
||||
module SearchMethods
|
||||
def active
|
||||
@@ -41,7 +41,7 @@ class Note < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:body_matches].present?
|
||||
@@ -144,7 +144,7 @@ class Note < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_post
|
||||
if Note.exists?(["is_active = ? AND post_id = ?", true, post_id])
|
||||
if Note.where(:is_active => true, :post_id => post_id).exists?
|
||||
execute_sql("UPDATE posts SET last_noted_at = ? WHERE id = ?", updated_at, post_id)
|
||||
else
|
||||
execute_sql("UPDATE posts SET last_noted_at = NULL WHERE id = ?", post_id)
|
||||
@@ -153,7 +153,8 @@ class Note < ActiveRecord::Base
|
||||
|
||||
def create_version
|
||||
CurrentUser.user.increment!(:note_update_count)
|
||||
update_column(:version, version.to_i + 1)
|
||||
Note.where(:id => id).update_all("version = coalesce(version, 0) + 1")
|
||||
reload
|
||||
|
||||
if merge_version?
|
||||
merge_version
|
||||
@@ -227,14 +228,15 @@ class Note < ActiveRecord::Base
|
||||
new_note.save
|
||||
end
|
||||
|
||||
def self.undo_changes_by_user(user_id)
|
||||
def self.undo_changes_by_user(vandal_id)
|
||||
transaction do
|
||||
notes = Note.joins(:versions).where(["note_versions.updater_id = ?", user_id]).select("DISTINCT notes.*").all
|
||||
NoteVersion.destroy_all(["updater_id = ?", user_id])
|
||||
notes.each do |note|
|
||||
first = note.versions.first
|
||||
if first
|
||||
note.revert_to!(first)
|
||||
note_ids = NoteVersion.where(:updater_id => vandal_id).select("note_id").distinct.map(&:note_id)
|
||||
NoteVersion.where(["updater_id = ?", vandal_id]).delete_all
|
||||
note_ids.each do |note_id|
|
||||
note = Note.find(note_id)
|
||||
most_recent = note.versions.last
|
||||
if most_recent
|
||||
note.revert_to!(most_recent)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,10 @@ class NoteVersion < ActiveRecord::Base
|
||||
before_validation :initialize_updater
|
||||
belongs_to :updater, :class_name => "User"
|
||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
||||
attr_accessible :note_id, :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :html_id, :version
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:updater_id]
|
||||
|
||||
@@ -6,7 +6,7 @@ class Pool < ActiveRecord::Base
|
||||
validates_inclusion_of :category, :in => %w(series collection)
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
has_many :versions, :class_name => "PoolVersion", :dependent => :destroy, :order => "pool_versions.id ASC"
|
||||
has_many :versions, lambda {order("pool_versions.id ASC")}, :class_name => "PoolVersion", :dependent => :destroy
|
||||
before_validation :normalize_post_ids
|
||||
before_validation :normalize_name
|
||||
before_validation :initialize_is_active, :on => :create
|
||||
@@ -46,7 +46,7 @@ class Pool < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:name_matches].present?
|
||||
@@ -105,7 +105,7 @@ class Pool < ActiveRecord::Base
|
||||
if name =~ /^\d+$/
|
||||
name.to_i
|
||||
else
|
||||
select_value_sql("SELECT id FROM pools WHERE lower(name) = ?", name.mb_chars.downcase.tr(" ", "_")).to_i
|
||||
select_value_sql("SELECT id FROM pools WHERE lower(name) = ?", name.downcase.tr(" ", "_")).to_i
|
||||
end
|
||||
end
|
||||
|
||||
@@ -314,10 +314,12 @@ class Pool < ActiveRecord::Base
|
||||
if post_ids_changed? || name_changed? || description_changed? || is_active_changed? || is_deleted_changed? || category_changed? || force
|
||||
last_version = versions.last
|
||||
|
||||
if last_version && CurrentUser.ip_addr == last_version.updater_ip_addr && CurrentUser.id == last_version.updater_id && last_version.created_at > 1.hour.ago
|
||||
if last_version && last_version.updater_ip_addr == CurrentUser.ip_addr && CurrentUser.user.id == last_version.updater_id && last_version.created_at > 1.hour.ago
|
||||
# merge
|
||||
last_version.update_column(:post_ids, post_ids)
|
||||
last_version.update_column(:name, name)
|
||||
else
|
||||
# create
|
||||
versions.create(:post_ids => post_ids, :name => name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ class PoolVersion < ActiveRecord::Base
|
||||
belongs_to :pool
|
||||
belongs_to :updater, :class_name => "User"
|
||||
before_validation :initialize_updater
|
||||
attr_accessible :pool_id, :is_deleted, :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :updater_id, :updater_ip_addr
|
||||
|
||||
module SearchMethods
|
||||
def for_user(user_id)
|
||||
@@ -12,7 +13,7 @@ class PoolVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id].present?
|
||||
|
||||
@@ -28,11 +28,11 @@ class Post < ActiveRecord::Base
|
||||
has_one :artist_commentary, :dependent => :destroy
|
||||
has_many :flags, :class_name => "PostFlag", :dependent => :destroy
|
||||
has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy
|
||||
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.updated_at ASC, post_versions.id ASC"
|
||||
has_many :versions, lambda {order("post_versions.updated_at ASC, post_versions.id ASC")}, :class_name => "PostVersion", :dependent => :destroy
|
||||
has_many :votes, :class_name => "PostVote", :dependent => :destroy
|
||||
has_many :notes, :dependent => :destroy
|
||||
has_many :comments, :order => "comments.id", :dependent => :destroy
|
||||
has_many :children, :class_name => "Post", :foreign_key => "parent_id", :order => "posts.id"
|
||||
has_many :comments, lambda {order("comments.id")}, :dependent => :destroy
|
||||
has_many :children, lambda {order("posts.id")}, :class_name => "Post", :foreign_key => "parent_id"
|
||||
has_many :disapprovals, :class_name => "PostDisapproval", :dependent => :destroy
|
||||
has_many :favorites, :dependent => :destroy
|
||||
validates_uniqueness_of :md5
|
||||
@@ -315,22 +315,22 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def increment_tag_post_counts
|
||||
Tag.update_all("post_count = post_count + 1", {:name => tag_array}) if tag_array.any?
|
||||
Tag.where(:name => tag_array).update_all("post_count = post_count + 1") if tag_array.any?
|
||||
end
|
||||
|
||||
def decrement_tag_post_counts
|
||||
Tag.update_all("post_count = post_count - 1", {:name => tag_array}) if tag_array.any?
|
||||
Tag.where(:name => tag_array).update_all("post_count = post_count - 1") if tag_array.any?
|
||||
end
|
||||
|
||||
def update_tag_post_counts
|
||||
decrement_tags = tag_array_was - tag_array
|
||||
increment_tags = tag_array - tag_array_was
|
||||
if increment_tags.any?
|
||||
Tag.update_all("post_count = post_count + 1", {:name => increment_tags})
|
||||
Tag.where(:name => increment_tags).update_all("post_count = post_count + 1")
|
||||
Post.expire_cache_for_all(increment_tags)
|
||||
end
|
||||
if decrement_tags.any?
|
||||
Tag.update_all("post_count = post_count - 1", {:name => decrement_tags})
|
||||
Tag.where(:name => decrement_tags).update_all("post_count = post_count - 1")
|
||||
Post.expire_cache_for_all(decrement_tags)
|
||||
end
|
||||
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
||||
@@ -417,7 +417,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
def remove_negated_tags(tags)
|
||||
negated_tags, tags = tags.partition {|x| x =~ /\A-/i}
|
||||
negated_tags.map!{|x| x[1..-1]}
|
||||
negated_tags = negated_tags.map {|x| x[1..-1]}
|
||||
return tags - negated_tags
|
||||
end
|
||||
|
||||
@@ -708,10 +708,10 @@ class Post < ActiveRecord::Base
|
||||
def vote!(score)
|
||||
if can_be_voted_by?(CurrentUser.user)
|
||||
if score == "up"
|
||||
Post.update_all("score = score + 1, up_score = up_score + 1", {:id => id})
|
||||
Post.where(:id => id).update_all("score = score + 1, up_score = up_score + 1")
|
||||
self.score += 1
|
||||
elsif score == "down"
|
||||
Post.update_all("score = score - 1, down_score = down_score - 1", {:id => id})
|
||||
Post.where(:id => id).update_all("score = score - 1, down_score = down_score - 1")
|
||||
self.score -= 1
|
||||
end
|
||||
|
||||
@@ -728,10 +728,10 @@ class Post < ActiveRecord::Base
|
||||
vote = votes.where("user_id = ?", CurrentUser.user.id).first
|
||||
|
||||
if vote.score == 1
|
||||
Post.update_all("score = score - 1, up_score = up_score - 1", {:id => id})
|
||||
Post.where(:id => id).update_all("score = score - 1, up_score = up_score - 1")
|
||||
self.score -= 1
|
||||
else
|
||||
Post.update_all("score = score + 1, down_score = down_score + 1", {:id => id})
|
||||
Post.where(:id => id).update_all("score = score + 1, down_score = down_score + 1")
|
||||
self.score += 1
|
||||
end
|
||||
|
||||
@@ -890,7 +890,7 @@ class Post < ActiveRecord::Base
|
||||
eldest = cached_children[0]
|
||||
siblings = cached_children[1..-1]
|
||||
eldest.update_column(:parent_id, nil)
|
||||
Post.update_all({:parent_id => eldest.id}, :id => siblings.map(&:id))
|
||||
Post.where(:id => siblings.map(&:id)).update_all(:parent_id => eldest.id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1008,7 +1008,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def create_new_version
|
||||
CurrentUser.increment!(:post_update_count)
|
||||
CurrentUser.user.increment!(:post_update_count)
|
||||
versions.create(
|
||||
:rating => rating,
|
||||
:source => source,
|
||||
@@ -1019,12 +1019,14 @@ class Post < ActiveRecord::Base
|
||||
|
||||
def merge_version
|
||||
prev = versions.last
|
||||
prev.update_attributes(
|
||||
:rating => rating,
|
||||
:source => source,
|
||||
:tags => tag_string,
|
||||
:parent_id => parent_id
|
||||
)
|
||||
if prev
|
||||
prev.update_attributes(
|
||||
:rating => rating,
|
||||
:source => source,
|
||||
:tags => tag_string,
|
||||
:parent_id => parent_id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def revert_to(target)
|
||||
@@ -1236,7 +1238,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:before_id].present?
|
||||
|
||||
@@ -8,6 +8,7 @@ class PostAppeal < ActiveRecord::Base
|
||||
validate :validate_creator_is_not_limited
|
||||
before_validation :initialize_creator, :on => :create
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
||||
attr_accessible :post_id, :post, :reason
|
||||
|
||||
module SearchMethods
|
||||
def resolved
|
||||
@@ -31,7 +32,7 @@ class PostAppeal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
|
||||
@@ -2,6 +2,7 @@ class PostDisapproval < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :user
|
||||
validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post"
|
||||
attr_accessible :post_id, :post, :user_id, :user
|
||||
|
||||
def self.prune!
|
||||
joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE").each do |post_disapproval|
|
||||
|
||||
@@ -9,6 +9,7 @@ class PostFlag < ActiveRecord::Base
|
||||
before_validation :initialize_creator, :on => :create
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already flagged this post"
|
||||
before_save :update_post
|
||||
attr_accessible :post, :post_id, :reason, :is_resolved
|
||||
|
||||
module SearchMethods
|
||||
def resolved
|
||||
@@ -32,7 +33,7 @@ class PostFlag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present? && (CurrentUser.user.is_janitor? || params[:creator_id].to_i == CurrentUser.user.id)
|
||||
|
||||
@@ -2,6 +2,7 @@ class PostVersion < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :updater, :class_name => "User"
|
||||
before_validation :initialize_updater
|
||||
attr_accessible :post_id, :is_status_locked, :is_rating_locked, :is_note_locked, :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :tags
|
||||
|
||||
module SearchMethods
|
||||
def for_user(user_id)
|
||||
@@ -13,7 +14,7 @@ class PostVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:updater_name].present?
|
||||
|
||||
@@ -5,6 +5,7 @@ class PostVote < ActiveRecord::Base
|
||||
before_validation :initialize_user, :on => :create
|
||||
validates_presence_of :post_id, :user_id, :score
|
||||
validates_inclusion_of :score, :in => [1, -1]
|
||||
attr_accessible :post_id, :user_id, :score
|
||||
|
||||
def score=(x)
|
||||
if x == "up"
|
||||
|
||||
@@ -113,7 +113,7 @@ class Tag < ActiveRecord::Base
|
||||
Post.raw_tag_match(name).find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
Post.update_all({:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character}, {:id => post.id})
|
||||
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -349,7 +349,7 @@ class Tag < ActiveRecord::Base
|
||||
output[:include] << tag[1..-1].mb_chars.downcase
|
||||
|
||||
elsif tag =~ /\*/
|
||||
matches = Tag.name_matches(tag.downcase).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||
matches = Tag.name_matches(tag.downcase).select("name").limit(Danbooru.config.tag_query_limit).order("post_count DESC").map(&:name)
|
||||
matches = ["~no_matches~"] if matches.empty?
|
||||
output[:include] += matches
|
||||
|
||||
@@ -421,8 +421,8 @@ class Tag < ActiveRecord::Base
|
||||
elsif $2.downcase == "any"
|
||||
q[:pool] = "any"
|
||||
elsif $2.include?("*")
|
||||
pools = Pool.name_matches($2).all(:select => "id", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC")
|
||||
q[:tags][:include] += pools.map!{|pool| "pool:#{pool.id}"}
|
||||
pools = Pool.name_matches($2).select("id").limit(Danbooru.config.tag_query_limit).order("post_count DESC")
|
||||
q[:tags][:include] += pools.map {|pool| "pool:#{pool.id}"}
|
||||
else
|
||||
q[:tags][:related] << "pool:#{Pool.name_to_id($2)}"
|
||||
end
|
||||
@@ -621,7 +621,7 @@ class Tag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:name_matches].present?
|
||||
|
||||
@@ -9,6 +9,7 @@ class TagAlias < ActiveRecord::Base
|
||||
validate :absence_of_transitive_relation
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :forum_topic
|
||||
attr_accessible :antecedent_name, :consequent_name, :forum_topic_id, :status
|
||||
|
||||
module SearchMethods
|
||||
def name_matches(name)
|
||||
@@ -20,7 +21,7 @@ class TagAlias < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name_matches].present?
|
||||
|
||||
@@ -10,6 +10,7 @@ class TagImplication < ActiveRecord::Base
|
||||
validate :absence_of_circular_relation
|
||||
validate :antecedent_is_not_aliased
|
||||
validate :consequent_is_not_aliased
|
||||
attr_accessible :antecedent_name, :consequent_name, :descendant_names, :forum_topic_id, :status, :forum_topic
|
||||
|
||||
module DescendantMethods
|
||||
extend ActiveSupport::Concern
|
||||
@@ -78,7 +79,7 @@ class TagImplication < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:id].present?
|
||||
|
||||
@@ -39,7 +39,7 @@ class TagSubscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def tag_query_array
|
||||
tag_query.scan(/[^\r\n]+/).map!(&:strip)
|
||||
tag_query.scan(/[^\r\n]+/).map(&:strip)
|
||||
end
|
||||
|
||||
def limit_tag_count
|
||||
@@ -80,7 +80,7 @@ class TagSubscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:creator_id]
|
||||
|
||||
@@ -13,6 +13,7 @@ class Upload < ActiveRecord::Base
|
||||
after_destroy :delete_temp_file
|
||||
validate :uploader_is_not_limited, :on => :create
|
||||
validate :file_or_source_is_present, :on => :create
|
||||
attr_accessible :file, :image_width, :image_height, :file_ext, :md5, :file_size, :as_pending, :source, :file_path, :content_type, :rating, :tag_string, :status, :backtrace, :post_id, :md5_confirmation
|
||||
|
||||
module ValidationMethods
|
||||
def uploader_is_not_limited
|
||||
@@ -316,7 +317,7 @@ class Upload < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:uploader_id].present?
|
||||
|
||||
@@ -40,11 +40,11 @@ class User < ActiveRecord::Base
|
||||
before_create :promote_to_admin_if_first_user
|
||||
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
|
||||
has_many :posts, :foreign_key => "uploader_id"
|
||||
has_many :bans, :order => "bans.id desc"
|
||||
has_one :recent_ban, :class_name => "Ban", :order => "bans.id desc"
|
||||
has_many :subscriptions, :class_name => "TagSubscription", :foreign_key => "creator_id", :order => "name"
|
||||
has_many :bans, lambda {order("bans.id desc")}
|
||||
has_one :recent_ban, lambda {order("bans.id desc")}, :class_name => "Ban"
|
||||
has_many :subscriptions, lambda {order("tag_subscriptions.name")}, :class_name => "TagSubscription", :foreign_key => "creator_id"
|
||||
has_many :note_versions, :foreign_key => "updater_id"
|
||||
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
||||
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
||||
belongs_to :inviter, :class_name => "User"
|
||||
after_update :create_mod_action
|
||||
|
||||
@@ -207,7 +207,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def clean_favorite_count?
|
||||
favorite_count < 0 || rand(100) < [Math.log(favorite_count, 2), 5].min
|
||||
favorite_count < 0 || Kernel.rand(100) < [Math.log(favorite_count, 2), 5].min
|
||||
end
|
||||
|
||||
def clean_favorite_count!
|
||||
@@ -628,7 +628,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name].present?
|
||||
|
||||
@@ -29,7 +29,7 @@ class UserFeedback < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:user_id].present?
|
||||
|
||||
@@ -9,6 +9,7 @@ class UserNameChangeRequest < ActiveRecord::Base
|
||||
validates_format_of :desired_name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||
before_validation :normalize_name
|
||||
after_create :notify_admins
|
||||
attr_accessible :status, :user_id, :original_name, :desired_name, :change_reason, :rejection_reason
|
||||
|
||||
def self.pending
|
||||
where(:status => "pending")
|
||||
|
||||
@@ -3,6 +3,7 @@ class UserPasswordResetNonce < ActiveRecord::Base
|
||||
validate :validate_existence_of_email
|
||||
before_validation :initialize_key, :on => :create
|
||||
after_create :deliver_notice
|
||||
attr_accessible :key, :nonce, :email
|
||||
|
||||
def self.prune!
|
||||
destroy_all(["created_at < ?", 1.week.ago])
|
||||
|
||||
@@ -12,8 +12,8 @@ class WikiPage < ActiveRecord::Base
|
||||
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}
|
||||
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC"
|
||||
has_one :artist, lambda {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title"
|
||||
has_many :versions, lambda {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy
|
||||
|
||||
module SearchMethods
|
||||
def titled(title)
|
||||
@@ -33,7 +33,7 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params = {})
|
||||
q = scoped
|
||||
q = where("true")
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:title].present?
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class WikiPageVersion < ActiveRecord::Base
|
||||
belongs_to :wiki_page
|
||||
belongs_to :updater, :class_name => "User"
|
||||
attr_accessible :wiki_page_id, :title, :body, :is_locked, :updater_id, :updater_ip_addr, :version
|
||||
|
||||
module SearchMethods
|
||||
def for_user(user_id)
|
||||
@@ -8,7 +9,7 @@ class WikiPageVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id].present?
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<td><%= compact_time commentary_version.updated_at %></td>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<td>
|
||||
<%= link_to "Revert to", revert_artist_commentary_path(commentary_version.post_id, :version_id => commentary_version.id), :remote => true, :method => :put, :confirm => "Are you sure you want to revert to this version?" %>
|
||||
<%= link_to "Revert to", revert_artist_commentary_path(commentary_version.post_id, :version_id => commentary_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</td>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<td>
|
||||
<%= link_to "Revert to", revert_artist_path(artist_version.artist_id, :version_id => artist_version.id), :method => :put, :confirm => "Are you sure you want to revert to this version?" %>
|
||||
<%= link_to "Revert to", revert_artist_path(artist_version.artist_id, :version_id => artist_version.id), :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||
<% if @artist.deletable_by?(CurrentUser.user) %>
|
||||
<% if @artist.is_active? %>
|
||||
<li><%= link_to "Delete", artist_path(@artist), :method => :delete, :confirm => "Are you sure you want to delete this artist?" %></li>
|
||||
<li><%= link_to "Delete", artist_path(@artist), :method => :delete, :data => {:confirm => "Are you sure you want to delete this artist?"} %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Undelete", undelete_artist_path(@artist), :method => :post, :confirm => "Are you sure you want to undelete this artist?" %></li>
|
||||
<li><%= link_to "Undelete", undelete_artist_path(@artist), :method => :post, :data => {:confirm => "Are you sure you want to undelete this artist?"} %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<% if @artist.is_banned? %>
|
||||
<li><%= link_to "Unban", unban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to unban this artist?" %></li>
|
||||
<li><%= link_to "Unban", unban_artist_path(@artist), :method => :put, :data => {:confirm => "Are you sure you want to unban this artist?"} %></li>
|
||||
|
||||
<% else %>
|
||||
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %></li>
|
||||
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :data => {:confirm => "Are you sure you want to ban this artist?"} %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<% if @post || @posts %>
|
||||
<li><%= link_to "Reply", new_comment_path(:post_id => comment.post_id), :class => "reply-link", "data-comment-id" => comment.id %></li>
|
||||
<% if comment.editable_by?(CurrentUser.user) %>
|
||||
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Are you sure you want to delete this comment?", :method => :delete, :remote => true %></li>
|
||||
<li><%= link_to "Delete", comment_path(comment.id), :data => {:confirm => "Are you sure you want to delete this comment?"}, :method => :delete, :remote => true %></li>
|
||||
<li><%= link_to "Edit", edit_comment_path(comment.id), :id => "edit_comment_link_#{comment.id}", :class => "edit_comment_link" %></li>
|
||||
<% end %>
|
||||
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<td><%= link_to_user dmail.to %></td>
|
||||
<td><%= link_to dmail.title, dmail_path(dmail) %></td>
|
||||
<td>
|
||||
<%= link_to "delete", dmail_path(dmail), :method => :delete, :confirm => "Are you sure you want to delete this Dmail?" %>
|
||||
<%= link_to "delete", dmail_path(dmail), :method => :delete, :data => {:confirm => "Are you sure you want to delete this Dmail?"} %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<% if forum_post.is_deleted %>
|
||||
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Delete", forum_post_path(forum_post.id), :confirm => "Are you sure you want to delete this forum post?", :method => :delete, :remote => true %></li>
|
||||
<li><%= link_to "Delete", forum_post_path(forum_post.id), :data => {:confirm => "Are you sure you want to delete this forum post?"}, :method => :delete, :remote => true %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
<% if @forum_topic.is_deleted? %>
|
||||
<li><%= link_to "Undelete", undelete_forum_topic_path(@forum_topic), :method => :post %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Delete", forum_topic_path(@forum_topic), :method => :delete, :confirm => "Are you sure you want to delete this forum topic?" %></li>
|
||||
<li><%= link_to "Delete", forum_topic_path(@forum_topic), :method => :delete, :data => {:confirm => "Are you sure you want to delete this forum topic?"} %></li>
|
||||
<% end %>
|
||||
<% if @forum_topic.is_locked? %>
|
||||
<li><%= link_to "Unlock", forum_topic_path(@forum_topic, :forum_topic => {:is_locked => false}), :method => :put %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Lock", forum_topic_path(@forum_topic, :forum_topic => {:is_locked => true}), :method => :put, :confirm => "Are you sure you want to lock this forum topic?" %></li>
|
||||
<li><%= link_to "Lock", forum_topic_path(@forum_topic, :forum_topic => {:is_locked => true}), :method => :put, :data => {:confirm => "Are you sure you want to lock this forum topic?"} %></li>
|
||||
<% end %>
|
||||
<% if @forum_topic.is_sticky? %>
|
||||
<li><%= link_to "Unsticky", forum_topic_path(@forum_topic, :forum_topic => {:is_sticky => false}), :method => :put %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Sticky", forum_topic_path(@forum_topic, :forum_topic => {:is_sticky => true}), :method => :put, :confirm => "Are you sure you want to sticky this forum topic?" %></li>
|
||||
<li><%= link_to "Sticky", forum_topic_path(@forum_topic, :forum_topic => {:is_sticky => true}), :method => :put, :data => {:confirm => "Are you sure you want to sticky this forum topic?"} %></li>
|
||||
<% end %>
|
||||
<li><%= link_to "Merge", new_merge_forum_topic_path(@forum_topic) %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<td><%= ip_ban.ip_addr %></td>
|
||||
<td><%= ip_ban.creator.name %></td>
|
||||
<td><%= ip_ban.reason %></td>
|
||||
<td><%= link_to "Unban", ip_ban_path(ip_ban), :remote => true, :method => :delete, :confirm => "Do your really want to unban #{ip_ban.creator.name}?" %></td>
|
||||
<td><%= link_to "Unban", ip_ban_path(ip_ban), :remote => true, :method => :delete, :data => {:confirm => "Do your really want to unban #{ip_ban.creator.name}?"} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<%= error_messages_for "ip_ban" %>
|
||||
|
||||
<%= simple_form_for(@ip_ban) do |f| %>
|
||||
<%= f.input :ip_addr, :label => "IP Address" %>
|
||||
<%= f.input :ip_addr, :label => "IP Address", :as => :string %>
|
||||
<%= f.input :reason, :input_html => {:size => "50x5"} %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<% end %>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<td>
|
||||
<%= link_to "Show", tag_alias_path(tag_alias) %>
|
||||
<% if tag_alias.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
|
||||
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
|
||||
@@ -107,7 +107,7 @@
|
||||
<td>
|
||||
<%= link_to "Show", tag_implication_path(tag_implication) %>
|
||||
<% if tag_implication.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
|
||||
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
|
||||
<% end %>
|
||||
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
|
||||
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<td><%= compact_time note_version.updated_at %></td>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<td>
|
||||
<%= link_to "Revert to", revert_note_path(note_version.note_id, :version_id => note_version.id), :remote => true, :method => :put, :confirm => "Are you sure you want to revert to this version?" %>
|
||||
<%= link_to "Revert to", revert_note_path(note_version.note_id, :version_id => note_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<% if @pool.is_deleted? %>
|
||||
<li><%= link_to "Undelete", undelete_pool_path(@pool), :method => :post, :remote => true %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Delete", pool_path(@pool), :method => :delete, :confirm => "Are you sure you want to delete this pool?", :remote => true %></li>
|
||||
<li><%= link_to "Delete", pool_path(@pool), :method => :delete, :data => {:confirm => "Are you sure you want to delete this pool?"}, :remote => true %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li><%= link_to "History", pool_versions_path(:search => {:pool_id => @pool.id}) %></li>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<li><%= link_to "Expunge", expunge_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "expunge", :confirm => "This will permanently delete this post (meaning the file will be deleted). Are you sure you want to delete this post?" %></li>
|
||||
<li><%= link_to "Expunge", expunge_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "expunge", :data => {:confirm => "This will permanently delete this post (meaning the file will be deleted). Are you sure you want to delete this post?"} %></li>
|
||||
<% end %>
|
||||
|
||||
<li id="mobile-version-list"><%= link_to "Mobile version", mobile_post_path(post) %></li>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<td>
|
||||
<%= link_to "Show", tag_alias_path(tag_alias) %>
|
||||
<% if tag_alias.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
|
||||
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<td>
|
||||
<%= link_to "Show", tag_implication_path(tag_implication) %>
|
||||
<% if tag_implication.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
|
||||
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
|
||||
<% end %>
|
||||
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
|
||||
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<li>|</li>
|
||||
<li><%= link_to "Show", tag_subscription_path(@tag_subscription) %></li>
|
||||
<li><%= link_to "Edit", edit_tag_subscription_path(@tag_subscription) %></li>
|
||||
<li><%= link_to "Delete", tag_subscription_path(@tag_subscription, :method => :delete, :confirm => "Are you sure you want to delete this tag subscription?") %></li>
|
||||
<li><%= link_to "Delete", tag_subscription_path(@tag_subscription, :method => :delete, :data => {:confirm => "Are you sure you want to delete this tag subscription?"}) %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
<% end %>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<td><%= tag_subscription.post_id_array.size %></td>
|
||||
<td>
|
||||
<%= link_to "edit", edit_tag_subscription_path(tag_subscription) %>
|
||||
| <%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :confirm => "Are you sure you want to delete this subscription?" %>
|
||||
| <%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
|
||||
| <%= link_to "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}") %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<td><%= format_text(feedback.body) %></td>
|
||||
<td>
|
||||
<% if feedback.creator_id == CurrentUser.id || CurrentUser.is_moderator? %>
|
||||
<%= link_to "delete", user_feedback_path(feedback), :method => :delete, :confirm => "Are you sure you want to delete this user feedback?" %>
|
||||
<%= link_to "delete", user_feedback_path(feedback), :method => :delete, :data => {:confirm => "Are you sure you want to delete this user feedback?"} %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
<li><%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this wiki page?" %></li>
|
||||
<li><%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this wiki page?"} %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -27,7 +27,7 @@
|
||||
<li>|</li>
|
||||
<li><%= link_to "Newest", wiki_page_path(@wiki_page_version.wiki_page_id) %></li>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to "Revert to", revert_wiki_page_path(@wiki_page_version.wiki_page_id, :version_id => @wiki_page_version.id), :method => :put, :confirm => "Are you sure you want to revert to this version?" %></li>
|
||||
<li><%= link_to "Revert to", revert_wiki_page_path(@wiki_page_version.wiki_page_id, :version_id => @wiki_page_version.id), :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user