refactored search
This commit is contained in:
@@ -397,7 +397,7 @@ Danbooru.Note = {
|
|||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var id = $this.data("id");
|
var id = $this.data("id");
|
||||||
if (id.match(/\d/)) {
|
if (id.match(/\d/)) {
|
||||||
window.location.href = "/note_versions?search[note_id_eq]=" + id;
|
window.location.href = "/note_versions?search[note_id]=" + id;
|
||||||
}
|
}
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/pools.json?search[name_contains]=" + req.term,
|
"/pools.json?search[name_matches]=" + req.term,
|
||||||
function(data) {
|
function(data) {
|
||||||
resp(data.map(function(x) {return x.name;}));
|
resp(data.map(function(x) {return x.name;}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class ForumTopicsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@forum_topic = ForumTopic.find(params[:id])
|
@forum_topic = ForumTopic.find(params[:id])
|
||||||
@forum_posts = ForumPost.search(:topic_id_eq => @forum_topic.id).order("forum_posts.id").paginate(params[:page])
|
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).order("forum_posts.id").paginate(params[:page])
|
||||||
respond_with(@forum_topic)
|
respond_with(@forum_topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ private
|
|||||||
|
|
||||||
if params[:title]
|
if params[:title]
|
||||||
params[:search] ||= {}
|
params[:search] ||= {}
|
||||||
params[:search][:title_eq] = params.delete(:title)
|
params[:search][:title] = params.delete(:title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class TagAliasesController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@tag_alias = TagAlias.create(params[:tag_alias])
|
@tag_alias = TagAlias.create(params[:tag_alias])
|
||||||
respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id}))
|
respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id => @tag_alias.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class TagImplicationsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@tag_implication = TagImplication.create(params[:tag_implication])
|
@tag_implication = TagImplication.create(params[:tag_implication])
|
||||||
respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id}))
|
respond_with(@tag_implication, :location => tag_implications_path(:search => {:id => @tag_implication.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ private
|
|||||||
def normalize_search_params
|
def normalize_search_params
|
||||||
if params[:title]
|
if params[:title]
|
||||||
params[:search] ||= {}
|
params[:search] ||= {}
|
||||||
params[:search][:title_equals] = params.delete(:title)
|
params[:search][:title] = params.delete(:title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ module ApplicationHelper
|
|||||||
submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id])
|
submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_field(method, options = {})
|
||||||
|
name = options[:label] || method.titleize
|
||||||
|
raw '<div class="input"><label for="search_' + method + '">' + name + '</label><input type="text" name="search_' + method + '" id="search_' + method + '"></div>'
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def nav_link_match(controller, url)
|
def nav_link_match(controller, url)
|
||||||
url =~ case controller
|
url =~ case controller
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ module Moderator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
if params[:user_id_eq]
|
if params[:user_id]
|
||||||
search_by_user_id(params[:user_id_eq].split(/,/))
|
search_by_user_id(params[:user_id].split(/,/))
|
||||||
elsif params[:user_name_eq]
|
elsif params[:user_name]
|
||||||
search_by_user_name(params[:user_name_eq].split(/,/))
|
search_by_user_name(params[:user_name].split(/,/))
|
||||||
elsif params[:ip_addr_eq]
|
elsif params[:ip_addr]
|
||||||
search_by_ip_addr(params[:ip_addr_eq].split(/,/))
|
search_by_ip_addr(params[:ip_addr].split(/,/))
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def artist
|
def artist
|
||||||
::Artist.name_equals(tag_string).first
|
::Artist.name_matches(tag_string).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_single_tag?
|
def is_single_tag?
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Advertisement < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def date_prefix
|
def date_prefix
|
||||||
created_at.strftime("%Y%m%d")
|
created_at.try(:strftime, "%Y%m%d")
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_path
|
def image_path
|
||||||
@@ -43,6 +43,7 @@ class Advertisement < ActiveRecord::Base
|
|||||||
def file=(f)
|
def file=(f)
|
||||||
if f.size > 0
|
if f.size > 0
|
||||||
self.file_name = unique_identifier + File.extname(f.original_filename)
|
self.file_name = unique_identifier + File.extname(f.original_filename)
|
||||||
|
FileUtils.mkdir_p(File.dirname(image_path))
|
||||||
|
|
||||||
if f.local_path
|
if f.local_path
|
||||||
FileUtils.cp(f.local_path, image_path)
|
FileUtils.cp(f.local_path, image_path)
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ class Artist < ActiveRecord::Base
|
|||||||
accepts_nested_attributes_for :wiki_page
|
accepts_nested_attributes_for :wiki_page
|
||||||
attr_accessible :body, :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :default, :admin]
|
attr_accessible :body, :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :default, :admin]
|
||||||
attr_accessible :is_banned, :as => :admin
|
attr_accessible :is_banned, :as => :admin
|
||||||
scope :active, where("is_active = true")
|
|
||||||
scope :banned, where("is_banned = true")
|
|
||||||
|
|
||||||
module UrlMethods
|
module UrlMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
@@ -191,67 +189,72 @@ class Artist < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
extend ActiveSupport::Concern
|
def active
|
||||||
|
where("is_active = true")
|
||||||
|
end
|
||||||
|
|
||||||
|
def banned
|
||||||
|
where("is_banned = true")
|
||||||
|
end
|
||||||
|
|
||||||
|
def url_matches(string)
|
||||||
|
matches = find_all_by_url(string).map(&:id)
|
||||||
|
|
||||||
|
if matches.any?
|
||||||
|
where("id in (?)", matches)
|
||||||
|
else
|
||||||
|
where("false")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module ClassMethods
|
def other_names_match(string)
|
||||||
def url_matches(string)
|
where("other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string))
|
||||||
matches = find_all_by_url(string).map(&:id)
|
end
|
||||||
|
|
||||||
|
def group_name_matches(name)
|
||||||
|
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
||||||
|
where("group_name LIKE ? ESCAPE E'\\\\'", stripped_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_matches(name)
|
||||||
|
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
||||||
|
where("name LIKE ? ESCAPE E'\\\\'", stripped_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def any_name_matches(name)
|
||||||
|
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
||||||
|
where("(name LIKE ? ESCAPE E'\\\\' OR other_names_index @@ to_tsquery('danbooru', ?))", stripped_name, normalize_name(name))
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = active
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
if matches.any?
|
case params[:name]
|
||||||
where("id in (?)", matches)
|
when /^http/
|
||||||
else
|
q = q.url_matches(params[:name])
|
||||||
where("false")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def other_names_match(string)
|
|
||||||
where("other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string))
|
|
||||||
end
|
|
||||||
|
|
||||||
def group_name_matches(name)
|
|
||||||
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
|
||||||
where("group_name LIKE ? ESCAPE E'\\\\'", stripped_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def name_matches(name)
|
|
||||||
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
|
||||||
where("name LIKE ? ESCAPE E'\\\\'", stripped_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def any_name_matches(name)
|
|
||||||
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
|
||||||
where("(name LIKE ? ESCAPE E'\\\\' OR other_names_index @@ to_tsquery('danbooru', ?))", stripped_name, normalize_name(name))
|
|
||||||
end
|
|
||||||
|
|
||||||
def search(params)
|
|
||||||
q = active
|
|
||||||
|
|
||||||
case params[:name]
|
when /name:(.+)/
|
||||||
when /^http/
|
q = q.name_matches($1)
|
||||||
q = q.url_matches(params[:name])
|
|
||||||
|
|
||||||
when /name:(.+)/
|
|
||||||
q = q.name_matches($1)
|
|
||||||
|
|
||||||
when /other:(.+)/
|
|
||||||
q = q.other_names_match($1)
|
|
||||||
|
|
||||||
when /group:(.+)/
|
|
||||||
q = q.group_name_matches($1)
|
|
||||||
|
|
||||||
when /status:banned/
|
|
||||||
q = q.banned
|
|
||||||
|
|
||||||
when /./
|
|
||||||
q = q.any_name_matches(params[:name])
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:id]
|
|
||||||
q = q.where("id = ?", params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
q
|
when /other:(.+)/
|
||||||
|
q = q.other_names_match($1)
|
||||||
|
|
||||||
|
when /group:(.+)/
|
||||||
|
q = q.group_name_matches($1)
|
||||||
|
|
||||||
|
when /status:banned/
|
||||||
|
q = q.banned
|
||||||
|
|
||||||
|
when /./
|
||||||
|
q = q.any_name_matches(params[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:id]
|
||||||
|
q = q.where("id = ?", params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -263,7 +266,7 @@ class Artist < ActiveRecord::Base
|
|||||||
include NoteMethods
|
include NoteMethods
|
||||||
include TagMethods
|
include TagMethods
|
||||||
include BanMethods
|
include BanMethods
|
||||||
include SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def status
|
def status
|
||||||
if is_banned?
|
if is_banned?
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class ArtistVersion < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.search(params)
|
def self.search(params)
|
||||||
q = scoped
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
if params[:artist_id]
|
if params[:artist_id]
|
||||||
q = q.where("artist_id = ?", params[:artist_id].to_i)
|
q = q.where("artist_id = ?", params[:artist_id].to_i)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Ban < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.search(params)
|
def self.search(params)
|
||||||
q = scoped
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
if params[:banner_name]
|
if params[:banner_name]
|
||||||
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].downcase)
|
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].downcase)
|
||||||
|
|||||||
@@ -9,57 +9,60 @@ class Comment < ActiveRecord::Base
|
|||||||
attr_accessible :body, :post_id
|
attr_accessible :body, :post_id
|
||||||
attr_accessor :do_not_bump_post
|
attr_accessor :do_not_bump_post
|
||||||
|
|
||||||
scope :recent, :order => "comments.id desc", :limit => 6
|
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
extend ActiveSupport::Concern
|
def recent
|
||||||
|
order("comments.id desc").limit(6)
|
||||||
|
end
|
||||||
|
|
||||||
module ClassMethods
|
def body_matches(query)
|
||||||
def body_matches(query)
|
where("body_index @@ plainto_tsquery(?)", query).order("comments.id DESC")
|
||||||
where("body_index @@ plainto_tsquery(?)", query).order("comments.id DESC")
|
end
|
||||||
|
|
||||||
|
def hidden(user)
|
||||||
|
where("score < ?", user.comment_threshold)
|
||||||
|
end
|
||||||
|
|
||||||
|
def visible(user)
|
||||||
|
where("score >= ?", user.comment_threshold)
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_tags_match(query)
|
||||||
|
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_creator(user_id)
|
||||||
|
where("creator_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_creator_name(user_name)
|
||||||
|
where("creator_id = (select _.id from users _ where lower(_.name) = lower(?))", user_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:body_matches]
|
||||||
|
q = q.body_matches(params[:body_matches])
|
||||||
end
|
end
|
||||||
|
|
||||||
def hidden(user)
|
if params[:post_tags_match]
|
||||||
where("score < ?", user.comment_threshold)
|
q = q.post_tags_match(params[:post_tags_match])
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible(user)
|
if params[:creator_name]
|
||||||
where("score >= ?", user.comment_threshold)
|
q = q.for_user_name(params[:creator_name])
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_tags_match(query)
|
if params[:creator_id]
|
||||||
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)
|
q = q.for_creator(params[:creator_id].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_creator(user_id)
|
q
|
||||||
where("creator_id = ?", user_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def for_creator_name(user_name)
|
|
||||||
where("creator_id = (select _.id from users _ where lower(_.name) = lower(?))", user_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def search(params)
|
|
||||||
q = scoped
|
|
||||||
|
|
||||||
if params[:body_matches]
|
|
||||||
q = q.body_matches(params[:body_matches])
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:post_tags_match]
|
|
||||||
q = q.post_tags_match(params[:post_tags_match])
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:creator_name]
|
|
||||||
q = q.for_user_name(params[:creator_name])
|
|
||||||
end
|
|
||||||
|
|
||||||
q
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
include SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
|
|||||||
@@ -10,16 +10,6 @@ class Dmail < ActiveRecord::Base
|
|||||||
after_create :update_recipient
|
after_create :update_recipient
|
||||||
after_create :send_dmail
|
after_create :send_dmail
|
||||||
attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name
|
attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name
|
||||||
scope :for, lambda {|user| where(["owner_id = ?", user])}
|
|
||||||
scope :inbox, where("to_id = owner_id")
|
|
||||||
scope :sent, where("from_id = owner_id")
|
|
||||||
scope :active, where(["is_deleted = ?", false])
|
|
||||||
scope :deleted, where(["is_deleted = ?", true])
|
|
||||||
scope :search_message, lambda {|query| where(["message_index @@ plainto_tsquery(?)", query])}
|
|
||||||
scope :unread, where("is_read = false and is_deleted = false")
|
|
||||||
scope :visible, lambda {where("owner_id = ?", CurrentUser.id)}
|
|
||||||
scope :to_name_matches, lambda {|name| where("to_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
|
|
||||||
scope :from_name_matches, lambda {|name| where("from_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
|
|
||||||
|
|
||||||
module AddressMethods
|
module AddressMethods
|
||||||
def to_name
|
def to_name
|
||||||
@@ -82,8 +72,82 @@ class Dmail < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def for(user)
|
||||||
|
where("owner_id = ?", user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def inbox
|
||||||
|
where("to_id = owner_id")
|
||||||
|
end
|
||||||
|
|
||||||
|
def sent
|
||||||
|
where("from_id = owner_id")
|
||||||
|
end
|
||||||
|
|
||||||
|
def active
|
||||||
|
where("is_deleted = ?", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def deleted
|
||||||
|
where("is_deleted = ?", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_message(query)
|
||||||
|
where("message_index @@ plainto_tsquery(?)", query)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unread
|
||||||
|
where("is_read = false and is_deleted = false")
|
||||||
|
end
|
||||||
|
|
||||||
|
def visible
|
||||||
|
where("owner_id = ?", CurrentUser.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_name_matches(name)
|
||||||
|
where("to_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def from_name_matches(name)
|
||||||
|
where("from_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:message_matches]
|
||||||
|
q = q.search_message(params[:message_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:owner_id]
|
||||||
|
q = q.for(params[:owner_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:to_name]
|
||||||
|
q = q.to_name_matches(params[:to_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:to_id]
|
||||||
|
q = q.where("to_id = ?", params[:to_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:from_name]
|
||||||
|
q = q.from_name_matches(params[:from_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:from_id]
|
||||||
|
q = q.where("from_id = ?", params[:from_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include AddressMethods
|
include AddressMethods
|
||||||
include FactoryMethods
|
include FactoryMethods
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def quoted_body
|
def quoted_body
|
||||||
"[quote]#{body}[/quote]"
|
"[quote]#{body}[/quote]"
|
||||||
|
|||||||
@@ -10,9 +10,53 @@ class ForumPost < ActiveRecord::Base
|
|||||||
validates_presence_of :body, :creator_id
|
validates_presence_of :body, :creator_id
|
||||||
validate :validate_topic_is_unlocked
|
validate :validate_topic_is_unlocked
|
||||||
before_destroy :validate_topic_is_unlocked
|
before_destroy :validate_topic_is_unlocked
|
||||||
scope :body_matches, lambda {|body| where(["forum_posts.text_index @@ plainto_tsquery(?)", body])}
|
|
||||||
scope :for_user, lambda {|user_id| where("forum_posts.creator_id = ?", user_id)}
|
module SearchMethods
|
||||||
scope :active, where("is_deleted = false")
|
def body_matches(body)
|
||||||
|
where("forum_posts.text_index @@ plainto_tsquery(?)", body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_user(user_id)
|
||||||
|
where("forum_posts.creator_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def creator_name(name)
|
||||||
|
where("forum_posts.creator_id = (select _.id from users _ where lower(_.name) = ?)", name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def active
|
||||||
|
where("is_deleted = false")
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:creator_id]
|
||||||
|
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:topic_id]
|
||||||
|
q = q.where("topic_id = ?", params[:topic_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:topic_title_matches]
|
||||||
|
q = q.joins(:topic).where("forum_topics.text_index @@ plainto_tsquery(?)", params[:topic_title_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:body_matches]
|
||||||
|
q = q.body_matches(params[:body_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:creator_name]
|
||||||
|
q = q.creator_name(params[:creator_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def self.new_reply(params)
|
def self.new_reply(params)
|
||||||
if params[:topic_id]
|
if params[:topic_id]
|
||||||
|
|||||||
@@ -10,10 +10,35 @@ class ForumTopic < ActiveRecord::Base
|
|||||||
before_validation :initialize_is_deleted, :on => :create
|
before_validation :initialize_is_deleted, :on => :create
|
||||||
validates_presence_of :title, :creator_id
|
validates_presence_of :title, :creator_id
|
||||||
validates_associated :original_post
|
validates_associated :original_post
|
||||||
scope :title_matches, lambda {|title| where(["text_index @@ plainto_tsquery(?)", title])}
|
|
||||||
scope :active, where("is_deleted = false")
|
|
||||||
accepts_nested_attributes_for :original_post
|
accepts_nested_attributes_for :original_post
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def title_matches(title)
|
||||||
|
where("text_index @@ plainto_tsquery(?)", title)
|
||||||
|
end
|
||||||
|
|
||||||
|
def active
|
||||||
|
where("is_deleted = false")
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:title_matches]
|
||||||
|
q = q.title_matches(params[:title_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:title]
|
||||||
|
q = q.where("title = ?", params[:title])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
creator_id == user.id || user.is_moderator?
|
creator_id == user.id || user.is_moderator?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,17 @@ class IpBan < ActiveRecord::Base
|
|||||||
def self.is_banned?(ip_addr)
|
def self.is_banned?(ip_addr)
|
||||||
exists?(["ip_addr = ?", ip_addr])
|
exists?(["ip_addr = ?", ip_addr])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:ip_addr]
|
||||||
|
q = q.where("ip_addr = ?", params[:ip_addr])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
|
||||||
def self.query(user_ids)
|
def self.query(user_ids)
|
||||||
comments = count_by_ip_addr("comments", user_ids, "creator_id", "ip_addr")
|
comments = count_by_ip_addr("comments", user_ids, "creator_id", "ip_addr")
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ class JanitorTrial < ActiveRecord::Base
|
|||||||
after_destroy :create_feedback
|
after_destroy :create_feedback
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
before_validation :initialize_creator
|
before_validation :initialize_creator
|
||||||
|
|
||||||
|
def self.search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:user_name]
|
||||||
|
q = q.where("user_id = (select _.id from users _ where lower(_.name) = ?)", params[:user_name].downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.id
|
self.creator_id = CurrentUser.id
|
||||||
|
|||||||
@@ -12,9 +12,45 @@ class Note < ActiveRecord::Base
|
|||||||
after_save :create_version
|
after_save :create_version
|
||||||
validate :post_must_not_be_note_locked
|
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, :html_id
|
||||||
scope :active, where("is_active = TRUE")
|
|
||||||
scope :body_matches, lambda {|query| where("body_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))}
|
module SearchMethods
|
||||||
scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)}
|
def active
|
||||||
|
where("is_active = TRUE")
|
||||||
|
end
|
||||||
|
|
||||||
|
def body_matches(query)
|
||||||
|
where("body_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_tags_match(query)
|
||||||
|
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)
|
||||||
|
end
|
||||||
|
|
||||||
|
def creator_name(name)
|
||||||
|
where("creator_id = (select _.id from users _ where lower(_.name) = ?)", name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:body_matches]
|
||||||
|
q = q.body_matches(params[:body_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:post_tags_match]
|
||||||
|
q = q.post_tags_match(params[:post_tags_match])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:creator_name]
|
||||||
|
q = q.creator_name(params[:creator_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def presenter
|
def presenter
|
||||||
@presenter ||= NotePresenter.new(self)
|
@presenter ||= NotePresenter.new(self)
|
||||||
|
|||||||
@@ -2,6 +2,21 @@ class NoteVersion < ActiveRecord::Base
|
|||||||
before_validation :initialize_updater
|
before_validation :initialize_updater
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
||||||
|
|
||||||
|
def self.search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:updater_id]
|
||||||
|
q = q.where("updater_id = ?", params[:updater_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:post_id]
|
||||||
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
|
||||||
def initialize_updater
|
def initialize_updater
|
||||||
self.updater_id = CurrentUser.id
|
self.updater_id = CurrentUser.id
|
||||||
|
|||||||
@@ -14,7 +14,33 @@ class Pool < ActiveRecord::Base
|
|||||||
before_destroy :create_mod_action_for_destroy
|
before_destroy :create_mod_action_for_destroy
|
||||||
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default]
|
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default]
|
||||||
attr_accessible :is_deleted, :as => [:janitor, :moderator, :admin]
|
attr_accessible :is_deleted, :as => [:janitor, :moderator, :admin]
|
||||||
scope :active, where("is_active = true and is_deleted = false")
|
|
||||||
|
module SearchMethods
|
||||||
|
def active
|
||||||
|
where("is_active = true and is_deleted = false")
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:name_matches]
|
||||||
|
q = q.where("name like ? escape E'\\\\'", params[:name_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:description_matches]
|
||||||
|
q = q.where("description like ? escape E'\\\\'", params[:description_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:creator_name]
|
||||||
|
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def self.name_to_id(name)
|
def self.name_to_id(name)
|
||||||
if name =~ /^\d+$/
|
if name =~ /^\d+$/
|
||||||
|
|||||||
@@ -5,7 +5,25 @@ class PoolVersion < ActiveRecord::Base
|
|||||||
belongs_to :pool
|
belongs_to :pool
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
before_validation :initialize_updater
|
before_validation :initialize_updater
|
||||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
|
||||||
|
module SearchMethods
|
||||||
|
def for_user(user_id)
|
||||||
|
where("updater_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:updater_id]
|
||||||
|
q = q.for_user(params[:updater_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_updater
|
def initialize_updater
|
||||||
self.updater_id = CurrentUser.id
|
self.updater_id = CurrentUser.id
|
||||||
|
|||||||
@@ -33,34 +33,6 @@ class Post < ActiveRecord::Base
|
|||||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default]
|
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default]
|
||||||
attr_accessible :is_rating_locked, :is_note_locked, :as => [:janitor, :moderator, :admin]
|
attr_accessible :is_rating_locked, :is_note_locked, :as => [:janitor, :moderator, :admin]
|
||||||
attr_accessible :is_status_locked, :as => [:admin]
|
attr_accessible :is_status_locked, :as => [:admin]
|
||||||
scope :pending, where(["is_pending = ?", true])
|
|
||||||
scope :pending_or_flagged, where(["(is_pending = ? OR is_flagged = ?)", true, true])
|
|
||||||
scope :undeleted, where(["is_deleted = ?", false])
|
|
||||||
scope :deleted, where(["is_deleted = ?", true])
|
|
||||||
scope :visible, lambda {|user| Danbooru.config.can_user_see_post_conditions(user)}
|
|
||||||
scope :commented_before, lambda {|date| where("last_commented_at < ?", date).order("last_commented_at DESC")}
|
|
||||||
scope :has_notes, where("last_noted_at is not null")
|
|
||||||
scope :for_user, lambda {|user_id| where(["uploader_id = ?", user_id])}
|
|
||||||
scope :available_for_moderation, lambda {|hidden| hidden.present? ? where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id]) : where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
|
|
||||||
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
|
|
||||||
scope :tag_match, lambda {|query| PostQueryBuilder.new(query).build}
|
|
||||||
scope :positive, where("score > 1")
|
|
||||||
scope :negative, where("score < -1")
|
|
||||||
scope :updater_name_matches, lambda {|name| where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
|
|
||||||
scope :after_id, Proc.new {|num|
|
|
||||||
if num.present?
|
|
||||||
where("id > ?", num.to_i).reorder("id asc")
|
|
||||||
else
|
|
||||||
where("true")
|
|
||||||
end
|
|
||||||
}
|
|
||||||
scope :before_id, Proc.new {|num|
|
|
||||||
if num.present?
|
|
||||||
where("id < ?", num.to_i).reorder("id desc")
|
|
||||||
else
|
|
||||||
where("true")
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
module FileMethods
|
module FileMethods
|
||||||
def distribute_files
|
def distribute_files
|
||||||
@@ -619,13 +591,13 @@ class Post < ActiveRecord::Base
|
|||||||
tags = tags.to_s.strip
|
tags = tags.to_s.strip
|
||||||
count = get_count_from_cache(tags)
|
count = get_count_from_cache(tags)
|
||||||
if count.nil?
|
if count.nil?
|
||||||
if tags.blank?
|
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
||||||
count = 1_000_000
|
count = Danbooru.config.blank_tag_search_fast_count
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
count = Post.tag_match(tags).undeleted.count
|
count = Post.tag_match(tags).undeleted.count
|
||||||
rescue ActiveRecord::StatementInvalid
|
rescue ActiveRecord::StatementInvalid
|
||||||
count = 1_000_000
|
count = Danbooru.config.blank_tag_search_fast_count || 1_000_000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -867,6 +839,103 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def pending
|
||||||
|
where("is_pending = ?", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending_or_flagged
|
||||||
|
where("(is_pending = ? OR is_flagged = ?)", true, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def undeleted
|
||||||
|
where("is_deleted = ?", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def deleted
|
||||||
|
where("is_deleted = ?", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def visible(user)
|
||||||
|
Danbooru.config.can_user_see_post_conditions(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def commented_before(date)
|
||||||
|
where("last_commented_at < ?", date).order("last_commented_at DESC")
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_notes
|
||||||
|
where("last_noted_at is not null")
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_user(user_id)
|
||||||
|
where("uploader_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def available_for_moderation(hidden)
|
||||||
|
if hidden.present?
|
||||||
|
where("id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
||||||
|
else
|
||||||
|
where("id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_from_moderation
|
||||||
|
where("id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def tag_match(query)
|
||||||
|
PostQueryBuilder.new(query).build
|
||||||
|
end
|
||||||
|
|
||||||
|
def positive
|
||||||
|
where("score > 1")
|
||||||
|
end
|
||||||
|
|
||||||
|
def negative
|
||||||
|
where("score < -1")
|
||||||
|
end
|
||||||
|
|
||||||
|
def updater_name_matches(name)
|
||||||
|
where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_id(num)
|
||||||
|
if num.present?
|
||||||
|
where("id > ?", num.to_i).reorder("id asc")
|
||||||
|
else
|
||||||
|
where("true")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def before_id(num)
|
||||||
|
if num.present?
|
||||||
|
where("id < ?", num.to_i).reorder("id desc")
|
||||||
|
else
|
||||||
|
where("true")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:before_id]
|
||||||
|
q = q.before_id(params[:before_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:after_id]
|
||||||
|
q = q.after_id(params[:after_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:tag_match]
|
||||||
|
q = q.tag_match(params[:tag_match])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include FileMethods
|
include FileMethods
|
||||||
include ImageMethods
|
include ImageMethods
|
||||||
include ApprovalMethods
|
include ApprovalMethods
|
||||||
@@ -883,6 +952,7 @@ class Post < ActiveRecord::Base
|
|||||||
include VersionMethods
|
include VersionMethods
|
||||||
include NoteMethods
|
include NoteMethods
|
||||||
include ApiMethods
|
include ApiMethods
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def reload(options = nil)
|
def reload(options = nil)
|
||||||
super
|
super
|
||||||
|
|||||||
@@ -8,8 +8,29 @@ class PostAppeal < ActiveRecord::Base
|
|||||||
validate :validate_creator_is_not_limited
|
validate :validate_creator_is_not_limited
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
||||||
scope :for_user, lambda {|user_id| where(["creator_id = ?", user_id])}
|
|
||||||
scope :recent, lambda {where(["created_at >= ?", 1.day.ago])}
|
module SearchMethods
|
||||||
|
def for_user(user_id)
|
||||||
|
where("creator_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def recent
|
||||||
|
where("created_at >= ?", 1.day.ago)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:post_id]
|
||||||
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if appeal_count_for_creator >= Danbooru.config.max_appeals_per_day
|
if appeal_count_for_creator >= Danbooru.config.max_appeals_per_day
|
||||||
|
|||||||
@@ -9,9 +9,33 @@ class PostFlag < ActiveRecord::Base
|
|||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already flagged this post"
|
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already flagged this post"
|
||||||
before_save :update_post
|
before_save :update_post
|
||||||
scope :resolved, where("is_resolved = ?", true)
|
|
||||||
scope :unresolved, where("is_resolved = ?", false)
|
module SearchMethods
|
||||||
scope :old, lambda {where("created_at <= ?", 3.days.ago)}
|
def resolved
|
||||||
|
where("is_resolved = ?", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unresolved
|
||||||
|
where("is_resolved = ?", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def old
|
||||||
|
where("created_at <= ?", 3.days.ago)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:post_id]
|
||||||
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def update_post
|
def update_post
|
||||||
post.update_column(:is_flagged, true)
|
post.update_column(:is_flagged, true)
|
||||||
|
|||||||
@@ -2,8 +2,37 @@ class PostVersion < ActiveRecord::Base
|
|||||||
belongs_to :post
|
belongs_to :post
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
before_validation :initialize_updater
|
before_validation :initialize_updater
|
||||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
|
||||||
scope :updater_name_matches, lambda {|name| where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
|
module SearchMethods
|
||||||
|
def for_user(user_id)
|
||||||
|
where("updater_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def updater_name(name)
|
||||||
|
where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:updater_name]
|
||||||
|
q = q.updater_name(params[:updater_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:updater_id]
|
||||||
|
q = q.where("updater_id = ?", params[:updater_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:post_id]
|
||||||
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def self.create_from_post(post)
|
def self.create_from_post(post)
|
||||||
if post.created_at == post.updated_at
|
if post.created_at == post.updated_at
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ class Tag < ActiveRecord::Base
|
|||||||
attr_accessible :category
|
attr_accessible :category
|
||||||
after_save :update_category_cache
|
after_save :update_category_cache
|
||||||
has_one :wiki_page, :foreign_key => "name", :primary_key => "title"
|
has_one :wiki_page, :foreign_key => "name", :primary_key => "title"
|
||||||
scope :name_matches, lambda {|name| where("name LIKE ? ESCAPE E'\\\\'", name.downcase.to_escaped_for_sql_like)}
|
|
||||||
scope :named, lambda {|name| where("name = ?", TagAlias.to_aliased([name]).join(""))}
|
|
||||||
|
|
||||||
class CategoryMapping
|
class CategoryMapping
|
||||||
Danbooru.config.reverse_tag_category_mapping.each do |value, category|
|
Danbooru.config.reverse_tag_category_mapping.each do |value, category|
|
||||||
@@ -365,6 +363,42 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def name_matches(name)
|
||||||
|
where("name LIKE ? ESCAPE E'\\\\'", name.downcase.to_escaped_for_sql_like)
|
||||||
|
end
|
||||||
|
|
||||||
|
def named(name)
|
||||||
|
where("name = ?", TagAlias.to_aliased([name]).join(""))
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:name_matches]
|
||||||
|
q = q.name_matches(params[:name_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:category]
|
||||||
|
q = q.where("category = ?", params[:category])
|
||||||
|
end
|
||||||
|
|
||||||
|
case params[:sort]
|
||||||
|
when "count"
|
||||||
|
q = q.order("post_count")
|
||||||
|
|
||||||
|
when "date"
|
||||||
|
q = q.order("created_at")
|
||||||
|
|
||||||
|
else
|
||||||
|
q = q.order("name")
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
extend CountMethods
|
extend CountMethods
|
||||||
extend ViewCountMethods
|
extend ViewCountMethods
|
||||||
include CategoryMethods
|
include CategoryMethods
|
||||||
@@ -373,4 +407,5 @@ class Tag < ActiveRecord::Base
|
|||||||
extend ParseMethods
|
extend ParseMethods
|
||||||
include RelationMethods
|
include RelationMethods
|
||||||
extend SuggestionMethods
|
extend SuggestionMethods
|
||||||
|
extend SearchMethods
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,8 +7,34 @@ class TagAlias < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :antecedent_name
|
validates_uniqueness_of :antecedent_name
|
||||||
validate :absence_of_transitive_relation
|
validate :absence_of_transitive_relation
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
scope :name_matches, lambda {|name| where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)}
|
|
||||||
|
module SearchMethods
|
||||||
|
def name_matches(name)
|
||||||
|
where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:name_matches]
|
||||||
|
q = q.name_matches(params[:name_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:antecedent_name]
|
||||||
|
q = q.where("antecedent_name = ?", params[:antecedent_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:id]
|
||||||
|
q = q.where("id = ?", params[:id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def self.to_aliased(names)
|
def self.to_aliased(names)
|
||||||
alias_hash = Cache.get_multi(names.flatten, "ta") do |name|
|
alias_hash = Cache.get_multi(names.flatten, "ta") do |name|
|
||||||
ta = TagAlias.find_by_antecedent_name(name)
|
ta = TagAlias.find_by_antecedent_name(name)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ class TagImplication < ActiveRecord::Base
|
|||||||
validates_presence_of :creator_id
|
validates_presence_of :creator_id
|
||||||
validates_uniqueness_of :antecedent_name, :scope => :consequent_name
|
validates_uniqueness_of :antecedent_name, :scope => :consequent_name
|
||||||
validate :absence_of_circular_relation
|
validate :absence_of_circular_relation
|
||||||
scope :name_matches, lambda {|name| where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)}
|
|
||||||
|
|
||||||
module DescendantMethods
|
module DescendantMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
@@ -68,8 +67,34 @@ class TagImplication < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def name_matches(name)
|
||||||
|
where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:id]
|
||||||
|
q = q.where("id = ?", params[:id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:name_matches]
|
||||||
|
q = q.name_matches(params[:name_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:antecedent_name]
|
||||||
|
q = q.where("antecedent_name = ?", params[:antecedent_name])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include DescendantMethods
|
include DescendantMethods
|
||||||
include ParentMethods
|
include ParentMethods
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ class TagSubscription < ActiveRecord::Base
|
|||||||
user.is_moderator? || creator_id == user.id
|
user.is_moderator? || creator_id == user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
end
|
||||||
|
|
||||||
def self.visible_to(user)
|
def self.visible_to(user)
|
||||||
where("(is_public = TRUE OR creator_id = ? OR ?)", user.id, user.is_moderator?)
|
where("(is_public = TRUE OR creator_id = ? OR ?)", user.id, user.is_moderator?)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class Upload < ActiveRecord::Base
|
|||||||
before_create :convert_cgi_file
|
before_create :convert_cgi_file
|
||||||
after_destroy :delete_temp_file
|
after_destroy :delete_temp_file
|
||||||
validate :uploader_is_not_limited
|
validate :uploader_is_not_limited
|
||||||
scope :uploaded_by, lambda {|user_id| where(["uploader_id = ?", user_id])}
|
|
||||||
scope :pending, where(:status => "pending")
|
|
||||||
|
|
||||||
module ValidationMethods
|
module ValidationMethods
|
||||||
def uploader_is_not_limited
|
def uploader_is_not_limited
|
||||||
@@ -149,7 +147,8 @@ class Upload < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
Danbooru.resize(source_path, resized_file_path_for(width), width, height, quality)
|
Danbooru.resize(source_path, resized_file_path_for(width), width, height, quality)
|
||||||
if width == Danbooru.config.small_image_width
|
|
||||||
|
if width == Danbooru.config.small_image_width && Danbooru.config.ssd_path
|
||||||
Danbooru.resize(source_path, ssd_file_path, width, height, quality)
|
Danbooru.resize(source_path, ssd_file_path, width, height, quality)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -302,6 +301,31 @@ class Upload < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def uploaded_by(user_id)
|
||||||
|
where("uploader_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending
|
||||||
|
where(:status => "pending")
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:uploader_id]
|
||||||
|
q = q.uploaded_by(params[:uploader_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:source]
|
||||||
|
q = q.where("source = ?", params[:source])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include ConversionMethods
|
include ConversionMethods
|
||||||
include ValidationMethods
|
include ValidationMethods
|
||||||
include FileMethods
|
include FileMethods
|
||||||
@@ -313,6 +337,7 @@ class Upload < ActiveRecord::Base
|
|||||||
include CgiFileMethods
|
include CgiFileMethods
|
||||||
include StatusMethods
|
include StatusMethods
|
||||||
include UploaderMethods
|
include UploaderMethods
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def presenter
|
def presenter
|
||||||
@presenter ||= UploadPresenter.new(self)
|
@presenter ||= UploadPresenter.new(self)
|
||||||
|
|||||||
@@ -40,10 +40,6 @@ class User < ActiveRecord::Base
|
|||||||
has_many :note_versions, :foreign_key => "updater_id"
|
has_many :note_versions, :foreign_key => "updater_id"
|
||||||
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
||||||
belongs_to :inviter, :class_name => "User"
|
belongs_to :inviter, :class_name => "User"
|
||||||
scope :named, lambda {|name| where(["lower(name) = ?", name])}
|
|
||||||
scope :admins, where("is_admin = TRUE")
|
|
||||||
scope :with_email, lambda {|email| email.blank? ? where("FALSE") : where(["email = ?", email])}
|
|
||||||
scope :find_for_password_reset, lambda {|name, email| email.blank? ? where("FALSE") : where(["name = ? AND email = ?", name, email])}
|
|
||||||
|
|
||||||
module BanMethods
|
module BanMethods
|
||||||
def validate_ip_addr_is_not_banned
|
def validate_ip_addr_is_not_banned
|
||||||
@@ -417,6 +413,51 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SearchMethods
|
||||||
|
def named(name)
|
||||||
|
where("lower(name) = ?", name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_matches(name)
|
||||||
|
where("lower(name) like ? escape E'\\\\'", name.to_escaped_for_sql_like)
|
||||||
|
end
|
||||||
|
|
||||||
|
def admins
|
||||||
|
where("is_admin = TRUE")
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_email(email)
|
||||||
|
if email.blank?
|
||||||
|
where("FALSE")
|
||||||
|
else
|
||||||
|
where("email = ?", email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_for_password_reset(name, email)
|
||||||
|
if email.blank?
|
||||||
|
where("FALSE")
|
||||||
|
else
|
||||||
|
where(["name = ? AND email = ?", name, email])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:name_matches]
|
||||||
|
q = q.name_matches(params[:name_matches])
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:min_level]
|
||||||
|
q = q.where("level >= ?", params[:min_level].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include BanMethods
|
include BanMethods
|
||||||
include NameMethods
|
include NameMethods
|
||||||
include PasswordMethods
|
include PasswordMethods
|
||||||
@@ -429,6 +470,7 @@ class User < ActiveRecord::Base
|
|||||||
include LimitMethods
|
include LimitMethods
|
||||||
include InvitationMethods
|
include InvitationMethods
|
||||||
include ApiMethods
|
include ApiMethods
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_default_image_size
|
def initialize_default_image_size
|
||||||
self.default_image_size = "large"
|
self.default_image_size = "large"
|
||||||
|
|||||||
@@ -6,11 +6,38 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
attr_accessible :body, :user_id, :category, :user_name
|
attr_accessible :body, :user_id, :category, :user_name
|
||||||
validates_presence_of :user, :creator, :body, :category
|
validates_presence_of :user, :creator, :body, :category
|
||||||
validate :creator_is_privileged
|
validate :creator_is_privileged
|
||||||
scope :positive, where("category = ?", "positive")
|
|
||||||
scope :neutral, where("category = ?", "neutral")
|
module SearchMethods
|
||||||
scope :negative, where("category = ?", "negative")
|
def positive
|
||||||
scope :for_user, lambda {|user_id| where("user_id = ?", user_id)}
|
where("category = ?", "positive")
|
||||||
|
end
|
||||||
|
|
||||||
|
def neutral
|
||||||
|
where("category = ?", "neutral")
|
||||||
|
end
|
||||||
|
|
||||||
|
def negative
|
||||||
|
where("category = ?", "negative")
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_user(user_id)
|
||||||
|
where("user_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:user_id]
|
||||||
|
q = q.for_user(params[:user_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.id
|
self.creator_id = CurrentUser.id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,26 +7,37 @@ class WikiPage < ActiveRecord::Base
|
|||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
validate :validate_locker_is_janitor
|
validate :validate_locker_is_janitor
|
||||||
attr_accessible :title, :body, :is_locked
|
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 :tag, :foreign_key => "name", :primary_key => "title"
|
||||||
has_one :artist, :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"
|
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC"
|
||||||
|
|
||||||
def self.build_relation(options = {})
|
module SearchMethods
|
||||||
relation = where()
|
def titled(title)
|
||||||
|
where("title = ?", title.downcase.tr(" ", "_"))
|
||||||
if options[:title]
|
|
||||||
relation = relation.where(["title LIKE ? ESCAPE E'\\\\'", options[:title].downcase.tr(" ", "_").to_escaped_for_sql_like])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:creator_id]
|
def recent
|
||||||
relation = relation.where(["creator_id = ?", options[:creator_id]])
|
order("updated_at DESC").limit(25)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params = {})
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:title]
|
||||||
|
q = q.where("title LIKE ? ESCAPE E'\\\\'", params[:title].downcase.tr(" ", "_").to_escaped_for_sql_like)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:creator_id]
|
||||||
|
q = q.where("creator_id = ?", params[:creator_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
end
|
end
|
||||||
|
|
||||||
relation
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def self.find_title_and_id(title)
|
def self.find_title_and_id(title)
|
||||||
titled(title).select("title, id").first
|
titled(title).select("title, id").first
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,29 @@
|
|||||||
class WikiPageVersion < ActiveRecord::Base
|
class WikiPageVersion < ActiveRecord::Base
|
||||||
belongs_to :wiki_page
|
belongs_to :wiki_page
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
|
||||||
|
module SearchMethods
|
||||||
|
def for_user(user_id)
|
||||||
|
where("updater_id = ?", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search(params)
|
||||||
|
q = scoped
|
||||||
|
return q if params.blank?
|
||||||
|
|
||||||
|
if params[:updater_id]
|
||||||
|
q = q.for_user(params[:updater_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:wiki_page_id]
|
||||||
|
q = q.where("wiki_page_id = ?", params[:wiki_page_id].to_i)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend SearchMethods
|
||||||
|
|
||||||
def updater_name
|
def updater_name
|
||||||
User.id_to_name(updater_id)
|
User.id_to_name(updater_id)
|
||||||
|
|||||||
@@ -70,27 +70,27 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def comments(template)
|
def comments(template)
|
||||||
template.link_to(Comment.for_user(user.id).count, template.comments_path(:search => {:creator_id_eq => user.id}))
|
template.link_to(Comment.for_user(user.id).count, template.comments_path(:search => {:creator_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_versions(template)
|
def post_versions(template)
|
||||||
template.link_to(user.post_update_count, template.post_versions_path(:search => {:updater_id_eq => user.id}))
|
template.link_to(user.post_update_count, template.post_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def note_versions(template)
|
def note_versions(template)
|
||||||
template.link_to(user.note_update_count, template.note_versions_path(:search => {:updater_id_eq => user.id}))
|
template.link_to(user.note_update_count, template.note_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def wiki_page_versions(template)
|
def wiki_page_versions(template)
|
||||||
template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id_eq => user.id}))
|
template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def forum_posts(template)
|
def forum_posts(template)
|
||||||
template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id_eq => user.id}))
|
template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_versions(template)
|
def pool_versions(template)
|
||||||
template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id_eq => user.id}))
|
template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def inviter(template)
|
def inviter(template)
|
||||||
@@ -110,7 +110,7 @@ class UserPresenter
|
|||||||
neutral = UserFeedback.for_user(user.id).neutral.count
|
neutral = UserFeedback.for_user(user.id).neutral.count
|
||||||
negative = UserFeedback.for_user(user.id).negative.count
|
negative = UserFeedback.for_user(user.id).negative.count
|
||||||
|
|
||||||
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id_eq => user.id}))
|
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscriptions(template)
|
def subscriptions(template)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<% if @artist && !@artist.new_record? %>
|
<% if @artist && !@artist.new_record? %>
|
||||||
<li>|</li>
|
<li>|</li>
|
||||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
||||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id_eq => @artist.id}) %></li>
|
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||||
<li><%= link_to "Show", artist_path(@artist) %></li>
|
<li><%= link_to "Show", artist_path(@artist) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -3,12 +3,9 @@
|
|||||||
<h1>Search Artists</h1>
|
<h1>Search Artists</h1>
|
||||||
|
|
||||||
<div id="search-form">
|
<div id="search-form">
|
||||||
<%= simple_form_for(@search) do |f| %>
|
<%= form_tag(artists_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :name_contains, :label => "Name", :required => false %>
|
<%= search_field "name" %>
|
||||||
<%= f.input :other_names_match, :label => "Other Names", :required => false %>
|
<%= submit_tag "Search" %>
|
||||||
<%= f.input :group_name_contains, :label => "Group Name", :required => false %>
|
|
||||||
<%= f.input :url_match, :label => "URL", :required => false %>
|
|
||||||
<%= f.button :submit, "Search" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h1>Search Comments</h1>
|
<h1>Search Comments</h1>
|
||||||
|
|
||||||
<%= simple_form_for(@search) do |f| %>
|
<%= form_tag(comments_path, :method => :get) do |f| %>
|
||||||
<%= hidden_field_tag "group_by", "comment" %>
|
<%= hidden_field_tag "group_by", "comment" %>
|
||||||
<%= f.input :body_matches, :label => "Body", :required => false %>
|
|
||||||
<%= f.input :for_user_name, :label => "User", :required => false %>
|
|
||||||
<%= f.input :post_tag_match, :label => "Tags", :required => false %>
|
|
||||||
|
|
||||||
<%= f.button :submit, "Search" %>
|
<%= search_field :body_matches, :label => "Body" %>
|
||||||
|
<%= search_field :creator_name, :label => "User" %>
|
||||||
|
<%= search_field :post_tags_match, :label => "Tags" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Received", dmails_path(:search => {:owner_id_eq => CurrentUser.id, :to_id_eq => CurrentUser.id}, :folder => "received") %></li>
|
<li><%= link_to "Received", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></li>
|
||||||
<li><%= link_to "Sent", dmails_path(:search => {:owner_id_eq => CurrentUser.id, :from_id_eq => CurrentUser.id}, :folder => "sent") %></li>
|
<li><%= link_to "Sent", dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent") %></li>
|
||||||
<li><%= link_to "New", new_dmail_path %></li>
|
<li><%= link_to "New", new_dmail_path %></li>
|
||||||
<li><%= link_to "Search", search_dmails_path %></li>
|
<li><%= link_to "Search", search_dmails_path %></li>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<div id="c-dmails">
|
<div id="c-dmails">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h1>Search Messages</h1>
|
<h1>Search Messages</h1>
|
||||||
<%= simple_form_for @search do |f| %>
|
<%= form_tag(dmails_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= hidden_field_tag :folder, params[:folder] %>
|
<%= hidden_field_tag :folder, params[:folder] %>
|
||||||
<%= f.input :title_contains, :required => false, :label => "Title" %>
|
|
||||||
<%= f.input :body_contains, :required => false, :label => "Body" %>
|
<%= search_field :message_matches, :label => "Message" %>
|
||||||
<%= f.input :to_name_matches, :required => false, :label => "To" %>
|
<%= search_field :to_name, :label => "To" %>
|
||||||
<%= f.input :from_name_matches, :required => false, :label => "From" %>
|
<%= search_field :from_name, :label => "From" %>
|
||||||
<%= f.button :submit, "Search" %>
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<div id="c-forum-topics">
|
<div id="c-forum-topics">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h1>Search Forum</h1>
|
<h1>Search Forum</h1>
|
||||||
<%= simple_form_for @search do |f| %>
|
<%= form_tag(forum_topics_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :topic_title_matches, :label => "Title", :required => false %>
|
<%= search_field :topic_title_matches, :label => "Title" %>
|
||||||
<%= f.input :body_matches, :label => "Body", :required => false %>
|
<%= search_field :body_matches, :label => "Body" %>
|
||||||
<%= f.button :submit, "Search" %>
|
<%= search_field :creator_name, :label => "Author" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% @dashboard.artists.each do |activity| %>
|
<% @dashboard.artists.each do |activity| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
||||||
<td><%= link_to activity.count, artist_versions_path(:search => {:updater_id_eq => activity.user.id}) %></td>
|
<td><%= link_to activity.count, artist_versions_path(:search => {:updater_id => activity.user.id}) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% @dashboard.notes.each do |activity| %>
|
<% @dashboard.notes.each do |activity| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
||||||
<td><%= link_to activity.count, note_versions_path(:search => {:updater_id_eq => activity.user.id}) %></td>
|
<td><%= link_to activity.count, note_versions_path(:search => {:updater_id => activity.user.id}) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% @dashboard.tags.each do |activity| %>
|
<% @dashboard.tags.each do |activity| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
||||||
<td><%= link_to activity.count, post_versions_path(:search => {:updater_id_eq => activity.user.id}) %></td>
|
<td><%= link_to activity.count, post_versions_path(:search => {:updater_id => activity.user.id}) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% @dashboard.wiki_pages.each do |activity| %>
|
<% @dashboard.wiki_pages.each do |activity| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
<td><%= mod_link_to_user(activity.user, :positive) %></td>
|
||||||
<td><%= link_to activity.count, wiki_page_versions_path(:search => {:updater_id_eq => activity.user.id}) %></td>
|
<td><%= link_to activity.count, wiki_page_versions_path(:search => {:updater_id => activity.user.id}) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label for="user_ids">Search IPs</label>
|
<label for="user_ids">Search IPs</label>
|
||||||
<%= text_field_tag "search[ip_addr_eq]", params[:ip_addrs] %>
|
<%= text_field_tag "search[ip_addr]", params[:ip_addrs] %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= submit_tag "Search" %>
|
<%= submit_tag "Search" %>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label for="user_ids">Search User IDs</label>
|
<label for="user_ids">Search User IDs</label>
|
||||||
<%= text_field_tag "search[user_id_eq]", params[:user_ids] %>
|
<%= text_field_tag "search[user_id]", params[:user_ids] %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= submit_tag "Search" %>
|
<%= submit_tag "Search" %>
|
||||||
|
|||||||
@@ -2,18 +2,10 @@
|
|||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h1>Search IP Addresses</h1>
|
<h1>Search IP Addresses</h1>
|
||||||
|
|
||||||
<%= form_tag(moderator_ip_addrs_path) do %>
|
<%= form_tag(moderator_ip_addrs_path, :class => "simple_form") do %>
|
||||||
<div class="input">
|
<%= search_field "user_name", :label => "User" %>
|
||||||
<label>User</label>
|
<%= search_field "ip_addr", :label => "IP Addr" %>
|
||||||
<%= text_field :search, :user_name %>
|
<%= submit_tag "Search" %>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input">
|
|
||||||
<label>IP Addr</label>
|
|
||||||
<%= text_field :search, :ip_addr %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= submit_tag %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
||||||
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %></td>
|
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id => note_version.note_id}) %></td>
|
||||||
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if CurrentUser.is_janitor? %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<h1>Search Notes</h1>
|
<h1>Search Notes</h1>
|
||||||
|
|
||||||
<%= simple_form_for @search do |f| %>
|
<%= form_tag(notes_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= hidden_field_tag :group_by, "note" %>
|
<%= hidden_field_tag :group_by, "note" %>
|
||||||
<%= f.input :body_matches, :label => "Body", :required => false %>
|
<%= search_field :body_matches, :label => "Body" %>
|
||||||
<%= f.input :post_tag_match, :label => "Tags", :required => false %>
|
<%= search_field :post_tags_match, :label => "Tags" %>
|
||||||
<%= f.button :submit, "Search" %>
|
<%= search_field :creator_name, :label => "Author" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<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, :confirm => "Are you sure you want to delete this pool?", :remote => true %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "History", pool_versions_path(:search => {:pool_id_eq => @pool.id}) %></li>
|
<li><%= link_to "History", pool_versions_path(:search => {:pool_id => @pool.id}) %></li>
|
||||||
<li><%= link_to "Order", edit_pool_order_path(@pool) %></li>
|
<li><%= link_to "Order", edit_pool_order_path(@pool) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<div id="c-pools">
|
<div id="c-pools">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<%= simple_form_for @search, :method => :get do |f| %>
|
<%= form_tag pools_path, :method => :get, :class => "simple_form" do %>
|
||||||
<%= f.input :name_contains, :label => "Name", :required => false %>
|
<%= search_field "name_matches", :label => "Name" %>
|
||||||
<%= f.input :description_contains, :label => "Description", :required => false %>
|
<%= search_field "description_matches", :label => "Description" %>
|
||||||
<%= f.button :submit, "Search" %>
|
<%= search_field "creator_name", :label => "Creator" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<h1>Search Changes</h1>
|
<h1>Search Changes</h1>
|
||||||
|
|
||||||
<div id="search">
|
<div id="search">
|
||||||
<%= simple_form_for(@search) do |f| %>
|
<%= form_tag(post_versions_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :updater_name_matches, :label => "User", :required => false %>
|
<%= search_field "updater_name", :label => "User" %>
|
||||||
<%= f.input :post_id_eq, :label => "Post", :required => false %>
|
<%= search_field "post_id", :label => "Post" %>
|
||||||
<%= f.button :submit, :value => "Search" %>
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
<section>
|
<section>
|
||||||
<h1>History</h1>
|
<h1>History</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><%= link_to "Tags", post_versions_path(:search => {:post_id_eq => @post.id}) %></li>
|
<li><%= link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||||
<li><%= link_to "Notes", note_versions_path(:search => {:post_id_eq => @post.id}) %></li>
|
<li><%= link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tags_path %></li>
|
<li><%= link_to "Listing", tags_path %></li>
|
||||||
<li><%= link_to "Search", search_tags_path %></li>
|
<li><%= link_to "Search", search_tags_path %></li>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:tags"}) %></li>
|
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:tags"}) %></li>
|
||||||
<% if @tag %>
|
<% if @tag %>
|
||||||
<li>|</li>
|
<li>|</li>
|
||||||
<li><%= link_to "Edit", edit_tag_path(@tag) %></li>
|
<li><%= link_to "Edit", edit_tag_path(@tag) %></li>
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
<div id="c-tags">
|
<div id="c-tags">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<%= simple_form_for(@search) do |f| %>
|
<%= form_tag(tags_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :name_matches, :required => false, :label => "Name" %>
|
<%= search_field "name_matches", :label => "Name" %>
|
||||||
<%= f.input :category_equals, :required => false, :label => "Category", :collection => Danbooru.config.canonical_tag_category_mapping.to_a %>
|
|
||||||
<%= f.input :meta_sort, :collection => [["Name", "name.asc"], ["Count", "post_count.desc"], ["Date", "created_at.desc"]], :label => "Sort", :required => false %>
|
<div class="input">
|
||||||
|
<label for="search_category">Category</label>
|
||||||
|
<%= select "search", "category", Tag.canonical_tag_category_mapping.to_a %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label for="search_sort">Sort</label>
|
||||||
|
<%= select "search", "sort", %w(name count date) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= f.button :submit, "Search" %>
|
<%= f.button :submit, "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You can <%= link_to "upload another file", new_upload_path %> or <%= link_to "view your current uploads", uploads_path(:search => {:uploader_id_eq => CurrentUser.id}) %>.
|
You can <%= link_to "upload another file", new_upload_path %> or <%= link_to "view your current uploads", uploads_path(:search => {:uploader_id => CurrentUser.id}) %>.
|
||||||
<% if CurrentUser.user.is_moderator? && @upload.is_pending? %>
|
<% if CurrentUser.user.is_moderator? && @upload.is_pending? %>
|
||||||
<%= link_to "Force update", upload_path(@upload, :format => "js"), :remote => true, :method => :put %>.
|
<%= link_to "Force update", upload_path(@upload, :format => "js"), :remote => true, :method => :put %>.
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<menu>
|
<menu>
|
||||||
<% if @user_feedback %>
|
<% if @user_feedback %>
|
||||||
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => @user_feedback.user_id}) %></li>
|
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => @user_feedback.user_id}) %></li>
|
||||||
<% elsif params[:search] && params[:search][:user_id_eq] %>
|
<% elsif params[:search] && params[:search][:user_id] %>
|
||||||
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => params[:search][:user_id_eq]}) %></li>
|
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => params[:search][:user_id]}) %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "New", new_user_feedback_path %></li>
|
<li><%= link_to "New", new_user_feedback_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% if @user.id == CurrentUser.id %>
|
<% if @user.id == CurrentUser.id %>
|
||||||
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
||||||
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
||||||
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_path(:search => {:owner_id_eq => CurrentUser.id, :to_id_eq => CurrentUser.id}) %></li>
|
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}) %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<h1>Users</h1>
|
<h1>Users</h1>
|
||||||
|
|
||||||
<% simple_form_for(@search) do |f| %>
|
<% form_tag(users_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :name_contains, :label => "Name" %>
|
<%= search_field "name_matches", :label => "Name" %>
|
||||||
<%= f.sort_link "Name", :name %>
|
<%= submit_tag "Search" %>
|
||||||
<%= f.sort_link "Date", :created_at_desc %>
|
|
||||||
<%= f.button :submit %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<table width="100%" class="striped">
|
<table width="100%" class="striped">
|
||||||
@@ -46,7 +44,7 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= link_to user.note_versions.count, note_versions_path(:search => {:updater_id_eq => user.id}) %></td>
|
<td><%= link_to user.note_versions.count, note_versions_path(:search => {:updater_id => user.id}) %></td>
|
||||||
<td><%= user.level_string %></td>
|
<td><%= user.level_string %></td>
|
||||||
<td><span title="<%= user.created_at %>"><%= time_ago_in_words user.created_at %> ago</span></td>
|
<td><span title="<%= user.created_at %>"><%= time_ago_in_words user.created_at %> ago</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
<div id="c-users">
|
<div id="c-users">
|
||||||
<div id="a-search">
|
<div id="a-search">
|
||||||
<%= simple_form_for(@search) do |f| %>
|
<%= form_tag(users_path, :method => :get, :class => "simple_form") do %>
|
||||||
<%= f.input :name_matches, :required => false, :label => "Name" %>
|
<%= search_field "name_matches", :label => "Name" %>
|
||||||
<%= f.button :submit, "Search" %>
|
|
||||||
|
<div class="input">
|
||||||
|
<label for="search_level">Min Level</label>
|
||||||
|
<%= select("search", "min_level", User.level_hash.to_a) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", wiki_pages_path %></li>
|
<li><%= link_to "Listing", wiki_pages_path %></li>
|
||||||
<li><%= link_to "New", new_wiki_page_path %></li>
|
<li><%= link_to "New", new_wiki_page_path %></li>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:wiki"}) %></li>
|
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:wiki"}) %></li>
|
||||||
<% if @wiki_page %>
|
<% if @wiki_page %>
|
||||||
<li>|</li>
|
<li>|</li>
|
||||||
<li><%= link_to "Posts (#{Post.fast_count(@wiki_page.title)})", posts_path(:tags => @wiki_page.title) %></li>
|
<li><%= link_to "Posts (#{Post.fast_count(@wiki_page.title)})", posts_path(:tags => @wiki_page.title) %></li>
|
||||||
<li><%= link_to "History", wiki_page_versions_path(:search => {:wiki_page_id_eq => @wiki_page.id}) %></li>
|
<li><%= link_to "History", wiki_page_versions_path(:search => {:wiki_page_id => @wiki_page.id}) %></li>
|
||||||
<% if CurrentUser.is_member? %>
|
<% if CurrentUser.is_member? %>
|
||||||
<% unless @wiki_page.new_record? %>
|
<% unless @wiki_page.new_record? %>
|
||||||
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
|
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
|
||||||
|
|||||||
@@ -251,6 +251,13 @@ module Danbooru
|
|||||||
1
|
1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Counting every post is typically expensive because it involves a sequential scan on
|
||||||
|
# potentially millions of rows. If this method returns a value, then blank searches
|
||||||
|
# will return that number for the fast_count call instead.
|
||||||
|
def blank_tag_search_fast_count
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def pixiv_login
|
def pixiv_login
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ FactoryGirl.define do
|
|||||||
uploader_ip_addr "127.0.0.1"
|
uploader_ip_addr "127.0.0.1"
|
||||||
tag_string "special"
|
tag_string "special"
|
||||||
status "pending"
|
status "pending"
|
||||||
|
server Socket.gethostname
|
||||||
|
|
||||||
factory(:source_upload) do
|
factory(:source_upload) do
|
||||||
source "http://www.google.com/intl/en_ALL/images/logo.gif"
|
source "http://www.google.com/intl/en_ALL/images/logo.gif"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ArtistVersionsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "get the index page when searching for something" do
|
should "get the index page when searching for something" do
|
||||||
get :index, {:search => {:name_equals => @artist.name}}
|
get :index, {:search => {:name => @artist.name}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class IpBansControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:ip_addr_equals => "1.2.3.4"}}, {:user_id => @admin.id}
|
get :index, {:search => {:ip_addr => "1.2.3.4"}}, {:user_id => @admin.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:user_name_equals => @user.name}}, {:user_id => @admin.id}
|
get :index, {:search => {:user_name => @user.name}}, {:user_id => @admin.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ module Moderator
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "find by ip addr" do
|
should "find by ip addr" do
|
||||||
get :index, {:search => {:ip_addr_eq => "127.0.0.1"}}, {:user_id => @user.id}
|
get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
should "find by user id" do
|
should "find by user id" do
|
||||||
get :index, {:search => {:user_id_eq => @user.id.to_s}}, {:user_id => @user.id}
|
get :index, {:search => {:user_id => @user.id.to_s}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
should "find by user name" do
|
should "find by user name" do
|
||||||
get :index, {:search => {:user_name_eq => @user.name}}, {:user_id => @user.id}
|
get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class NoteVersionsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all versions that match the search criteria" do
|
should "list all versions that match the search criteria" do
|
||||||
get :index, {:search => {:updater_id_equals => @user_2.id}}
|
get :index, {:search => {:updater_id => @user_2.id}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil(assigns(:note_versions))
|
assert_not_nil(assigns(:note_versions))
|
||||||
assert_equal(1, assigns(:note_versions).size)
|
assert_equal(1, assigns(:note_versions).size)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class PoolVersionsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all versions that match the search criteria" do
|
should "list all versions that match the search criteria" do
|
||||||
get :index, {:search => {:updater_id_equals => @user_2.id}}
|
get :index, {:search => {:updater_id => @user_2.id}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil(assigns(:pool_versions))
|
assert_not_nil(assigns(:pool_versions))
|
||||||
assert_equal(1, assigns(:pool_versions).size)
|
assert_equal(1, assigns(:pool_versions).size)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class PostAppealsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:post_id_equals => @post_appeal.post_id}}, {:user_id => @user.id}
|
get :index, {:search => {:post_id => @post_appeal.post_id}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class PostFlagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:post_id_equals => @post_flag.post_id}}, {:user_id => @user.id}
|
get :index, {:search => {:post_id => @post_flag.post_id}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class PostVersionsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all versions that match the search criteria" do
|
should "list all versions that match the search criteria" do
|
||||||
get :index, {:search => {:post_id_equals => @post.id}}
|
get :index, {:search => {:post_id => @post.id}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil(assigns(:post_versions))
|
assert_not_nil(assigns(:post_versions))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all tag_aliass (with search)" do
|
should "list all tag_aliass (with search)" do
|
||||||
get :index, {:search => {:antecedent_name_matches => "aaa"}}
|
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all tag_implications (with search)" do
|
should "list all tag_implications (with search)" do
|
||||||
get :index, {:search => {:antecedent_name_matches => "aaa"}}
|
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class TagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:name_equals => "aaa"}}
|
get :index, {:search => {:name_matches => "aaa"}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:source_equals => @upload.source}}, {:user_id => @user.id}
|
get :index, {:search => {:source => @upload.source}}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "with search parameters" do
|
context "with search parameters" do
|
||||||
should "render" do
|
should "render" do
|
||||||
get :index, {:search => {:user_id_equals => @user.id}}, {:user_id => @critic.id}
|
get :index, {:search => {:user_id => @user.id}}, {:user_id => @critic.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class WikiPageVersionsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all versions that match the search criteria" do
|
should "list all versions that match the search criteria" do
|
||||||
get :index, {:search => {:wiki_page_id_equals => @wiki_page.id}}
|
get :index, {:search => {:wiki_page_id => @wiki_page.id}}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil(assigns(:wiki_page_versions))
|
assert_not_nil(assigns(:wiki_page_versions))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "list all wiki_pages (with search)" do
|
should "list all wiki_pages (with search)" do
|
||||||
get :index, {:search => {:title_matches => "abc"}}
|
get :index, {:search => {:title => "abc"}}
|
||||||
assert_redirected_to(wiki_page_path(@wiki_page_abc))
|
assert_redirected_to(wiki_page_path(@wiki_page_abc))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ require 'test_helper'
|
|||||||
class AdvertisementTest < ActiveSupport::TestCase
|
class AdvertisementTest < ActiveSupport::TestCase
|
||||||
context "An advertisement" do
|
context "An advertisement" do
|
||||||
setup do
|
setup do
|
||||||
|
Danbooru.config.stubs(:advertisement_path).returns("/tmp")
|
||||||
@ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"))
|
@ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
||||||
cat_or_fish.reload
|
cat_or_fish.reload
|
||||||
assert_equal("yuu", cat_or_fish.member_names)
|
assert_equal("yuu", cat_or_fish.member_names)
|
||||||
assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first)
|
assert_not_nil(Artist.search(:name => "group:cat_or_fish").first)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an associated wiki" do
|
should "have an associated wiki" do
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module Sources
|
|||||||
first_tag = @site.tags.first
|
first_tag = @site.tags.first
|
||||||
assert_equal(2, first_tag.size)
|
assert_equal(2, first_tag.size)
|
||||||
assert(first_tag[0] =~ /./)
|
assert(first_tag[0] =~ /./)
|
||||||
assert(first_tag[1] =~ /tags\.php\?tag=/)
|
assert(first_tag[1] =~ /search\.php/)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "convert a page into a json representation" do
|
should "convert a page into a json representation" do
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ class UploadTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
|
Delayed::Worker.delay_jobs = true
|
||||||
|
|
||||||
@upload.delete_temp_file if @upload
|
@upload.delete_temp_file if @upload
|
||||||
end
|
end
|
||||||
@@ -122,7 +124,7 @@ class UploadTest < ActiveSupport::TestCase
|
|||||||
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
||||||
assert_equal(6197, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
assert_equal(6197, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
||||||
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
||||||
assert_equal(117877, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
assert_equal(108224, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user