refactored search
This commit is contained in:
@@ -397,7 +397,7 @@ Danbooru.Note = {
|
||||
var $this = $(this);
|
||||
var id = $this.data("id");
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.getJSON(
|
||||
"/pools.json?search[name_contains]=" + req.term,
|
||||
"/pools.json?search[name_matches]=" + req.term,
|
||||
function(data) {
|
||||
resp(data.map(function(x) {return x.name;}));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class ForumTopicsController < ApplicationController
|
||||
|
||||
def show
|
||||
@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)
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ private
|
||||
|
||||
if params[:title]
|
||||
params[:search] ||= {}
|
||||
params[:search][:title_eq] = params.delete(:title)
|
||||
params[:search][:title] = params.delete(:title)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TagAliasesController < ApplicationController
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -15,7 +15,7 @@ class TagImplicationsController < ApplicationController
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -68,7 +68,7 @@ private
|
||||
def normalize_search_params
|
||||
if params[:title]
|
||||
params[:search] ||= {}
|
||||
params[:search][:title_equals] = params.delete(:title)
|
||||
params[:search][:title] = params.delete(:title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,6 +75,11 @@ module ApplicationHelper
|
||||
submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id])
|
||||
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
|
||||
def nav_link_match(controller, url)
|
||||
url =~ case controller
|
||||
|
||||
@@ -8,12 +8,12 @@ module Moderator
|
||||
end
|
||||
|
||||
def execute
|
||||
if params[:user_id_eq]
|
||||
search_by_user_id(params[:user_id_eq].split(/,/))
|
||||
elsif params[:user_name_eq]
|
||||
search_by_user_name(params[:user_name_eq].split(/,/))
|
||||
elsif params[:ip_addr_eq]
|
||||
search_by_ip_addr(params[:ip_addr_eq].split(/,/))
|
||||
if params[:user_id]
|
||||
search_by_user_id(params[:user_id].split(/,/))
|
||||
elsif params[:user_name]
|
||||
search_by_user_name(params[:user_name].split(/,/))
|
||||
elsif params[:ip_addr]
|
||||
search_by_ip_addr(params[:ip_addr].split(/,/))
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def artist
|
||||
::Artist.name_equals(tag_string).first
|
||||
::Artist.name_matches(tag_string).first
|
||||
end
|
||||
|
||||
def is_single_tag?
|
||||
|
||||
@@ -29,7 +29,7 @@ class Advertisement < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def date_prefix
|
||||
created_at.strftime("%Y%m%d")
|
||||
created_at.try(:strftime, "%Y%m%d")
|
||||
end
|
||||
|
||||
def image_path
|
||||
@@ -43,6 +43,7 @@ class Advertisement < ActiveRecord::Base
|
||||
def file=(f)
|
||||
if f.size > 0
|
||||
self.file_name = unique_identifier + File.extname(f.original_filename)
|
||||
FileUtils.mkdir_p(File.dirname(image_path))
|
||||
|
||||
if f.local_path
|
||||
FileUtils.cp(f.local_path, image_path)
|
||||
|
||||
@@ -14,8 +14,6 @@ class Artist < ActiveRecord::Base
|
||||
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 :is_banned, :as => :admin
|
||||
scope :active, where("is_active = true")
|
||||
scope :banned, where("is_banned = true")
|
||||
|
||||
module UrlMethods
|
||||
extend ActiveSupport::Concern
|
||||
@@ -191,67 +189,72 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
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 url_matches(string)
|
||||
matches = find_all_by_url(string).map(&:id)
|
||||
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
|
||||
return q if params.blank?
|
||||
|
||||
if matches.any?
|
||||
where("id in (?)", matches)
|
||||
else
|
||||
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 /^http/
|
||||
q = q.url_matches(params[:name])
|
||||
|
||||
case params[:name]
|
||||
when /^http/
|
||||
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
|
||||
when /name:(.+)/
|
||||
q = q.name_matches($1)
|
||||
|
||||
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
|
||||
|
||||
if params[:id]
|
||||
q = q.where("id = ?", params[:id])
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -263,7 +266,7 @@ class Artist < ActiveRecord::Base
|
||||
include NoteMethods
|
||||
include TagMethods
|
||||
include BanMethods
|
||||
include SearchMethods
|
||||
extend SearchMethods
|
||||
|
||||
def status
|
||||
if is_banned?
|
||||
|
||||
@@ -4,6 +4,7 @@ class ArtistVersion < ActiveRecord::Base
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
if params[:artist_id]
|
||||
q = q.where("artist_id = ?", params[:artist_id].to_i)
|
||||
|
||||
@@ -13,6 +13,7 @@ class Ban < ActiveRecord::Base
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
if params[:banner_name]
|
||||
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_accessor :do_not_bump_post
|
||||
|
||||
scope :recent, :order => "comments.id desc", :limit => 6
|
||||
|
||||
module SearchMethods
|
||||
extend ActiveSupport::Concern
|
||||
def recent
|
||||
order("comments.id desc").limit(6)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def body_matches(query)
|
||||
where("body_index @@ plainto_tsquery(?)", query).order("comments.id DESC")
|
||||
def body_matches(query)
|
||||
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
|
||||
|
||||
def hidden(user)
|
||||
where("score < ?", user.comment_threshold)
|
||||
if params[:post_tags_match]
|
||||
q = q.post_tags_match(params[:post_tags_match])
|
||||
end
|
||||
|
||||
def visible(user)
|
||||
where("score >= ?", user.comment_threshold)
|
||||
if params[:creator_name]
|
||||
q = q.for_user_name(params[:creator_name])
|
||||
end
|
||||
|
||||
def post_tags_match(query)
|
||||
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)
|
||||
if params[:creator_id]
|
||||
q = q.for_creator(params[:creator_id].to_i)
|
||||
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
|
||||
|
||||
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
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
include SearchMethods
|
||||
extend SearchMethods
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.user.id
|
||||
|
||||
@@ -10,16 +10,6 @@ class Dmail < ActiveRecord::Base
|
||||
after_create :update_recipient
|
||||
after_create :send_dmail
|
||||
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
|
||||
def to_name
|
||||
@@ -82,8 +72,82 @@ class Dmail < ActiveRecord::Base
|
||||
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 FactoryMethods
|
||||
extend SearchMethods
|
||||
|
||||
def quoted_body
|
||||
"[quote]#{body}[/quote]"
|
||||
|
||||
@@ -10,9 +10,53 @@ class ForumPost < ActiveRecord::Base
|
||||
validates_presence_of :body, :creator_id
|
||||
validate :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)}
|
||||
scope :active, where("is_deleted = false")
|
||||
|
||||
module SearchMethods
|
||||
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)
|
||||
if params[:topic_id]
|
||||
|
||||
@@ -10,10 +10,35 @@ class ForumTopic < ActiveRecord::Base
|
||||
before_validation :initialize_is_deleted, :on => :create
|
||||
validates_presence_of :title, :creator_id
|
||||
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
|
||||
|
||||
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)
|
||||
creator_id == user.id || user.is_moderator?
|
||||
end
|
||||
|
||||
@@ -7,6 +7,17 @@ class IpBan < ActiveRecord::Base
|
||||
def self.is_banned?(ip_addr)
|
||||
exists?(["ip_addr = ?", ip_addr])
|
||||
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)
|
||||
comments = count_by_ip_addr("comments", user_ids, "creator_id", "ip_addr")
|
||||
|
||||
@@ -6,6 +6,17 @@ class JanitorTrial < ActiveRecord::Base
|
||||
after_destroy :create_feedback
|
||||
validates_presence_of :user
|
||||
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
|
||||
self.creator_id = CurrentUser.id
|
||||
|
||||
@@ -12,9 +12,45 @@ class Note < ActiveRecord::Base
|
||||
after_save :create_version
|
||||
validate :post_must_not_be_note_locked
|
||||
attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :html_id
|
||||
scope :active, where("is_active = TRUE")
|
||||
scope :body_matches, lambda {|query| where("body_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))}
|
||||
scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)}
|
||||
|
||||
module SearchMethods
|
||||
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
|
||||
@presenter ||= NotePresenter.new(self)
|
||||
|
||||
@@ -2,6 +2,21 @@ class NoteVersion < ActiveRecord::Base
|
||||
before_validation :initialize_updater
|
||||
belongs_to :updater, :class_name => "User"
|
||||
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
||||
|
||||
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
|
||||
self.updater_id = CurrentUser.id
|
||||
|
||||
@@ -14,7 +14,33 @@ class Pool < ActiveRecord::Base
|
||||
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 :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)
|
||||
if name =~ /^\d+$/
|
||||
|
||||
@@ -5,7 +5,25 @@ class PoolVersion < ActiveRecord::Base
|
||||
belongs_to :pool
|
||||
belongs_to :updater, :class_name => "User"
|
||||
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
|
||||
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 :is_rating_locked, :is_note_locked, :as => [:janitor, :moderator, :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
|
||||
def distribute_files
|
||||
@@ -619,13 +591,13 @@ class Post < ActiveRecord::Base
|
||||
tags = tags.to_s.strip
|
||||
count = get_count_from_cache(tags)
|
||||
if count.nil?
|
||||
if tags.blank?
|
||||
count = 1_000_000
|
||||
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
||||
count = Danbooru.config.blank_tag_search_fast_count
|
||||
else
|
||||
begin
|
||||
count = Post.tag_match(tags).undeleted.count
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
count = 1_000_000
|
||||
count = Danbooru.config.blank_tag_search_fast_count || 1_000_000
|
||||
end
|
||||
end
|
||||
|
||||
@@ -867,6 +839,103 @@ class Post < ActiveRecord::Base
|
||||
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 ImageMethods
|
||||
include ApprovalMethods
|
||||
@@ -883,6 +952,7 @@ class Post < ActiveRecord::Base
|
||||
include VersionMethods
|
||||
include NoteMethods
|
||||
include ApiMethods
|
||||
extend SearchMethods
|
||||
|
||||
def reload(options = nil)
|
||||
super
|
||||
|
||||
@@ -8,8 +8,29 @@ class PostAppeal < ActiveRecord::Base
|
||||
validate :validate_creator_is_not_limited
|
||||
before_validation :initialize_creator, :on => :create
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
||||
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
|
||||
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
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already flagged this post"
|
||||
before_save :update_post
|
||||
scope :resolved, where("is_resolved = ?", true)
|
||||
scope :unresolved, where("is_resolved = ?", false)
|
||||
scope :old, lambda {where("created_at <= ?", 3.days.ago)}
|
||||
|
||||
module SearchMethods
|
||||
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
|
||||
post.update_column(:is_flagged, true)
|
||||
|
||||
@@ -2,8 +2,37 @@ class PostVersion < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :updater, :class_name => "User"
|
||||
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)
|
||||
if post.created_at == post.updated_at
|
||||
|
||||
@@ -2,8 +2,6 @@ class Tag < ActiveRecord::Base
|
||||
attr_accessible :category
|
||||
after_save :update_category_cache
|
||||
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
|
||||
Danbooru.config.reverse_tag_category_mapping.each do |value, category|
|
||||
@@ -365,6 +363,42 @@ class Tag < ActiveRecord::Base
|
||||
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 ViewCountMethods
|
||||
include CategoryMethods
|
||||
@@ -373,4 +407,5 @@ class Tag < ActiveRecord::Base
|
||||
extend ParseMethods
|
||||
include RelationMethods
|
||||
extend SuggestionMethods
|
||||
extend SearchMethods
|
||||
end
|
||||
|
||||
@@ -7,8 +7,34 @@ class TagAlias < ActiveRecord::Base
|
||||
validates_uniqueness_of :antecedent_name
|
||||
validate :absence_of_transitive_relation
|
||||
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)
|
||||
alias_hash = Cache.get_multi(names.flatten, "ta") do |name|
|
||||
ta = TagAlias.find_by_antecedent_name(name)
|
||||
|
||||
@@ -6,7 +6,6 @@ class TagImplication < ActiveRecord::Base
|
||||
validates_presence_of :creator_id
|
||||
validates_uniqueness_of :antecedent_name, :scope => :consequent_name
|
||||
validate :absence_of_circular_relation
|
||||
scope :name_matches, lambda {|name| where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)}
|
||||
|
||||
module DescendantMethods
|
||||
extend ActiveSupport::Concern
|
||||
@@ -68,8 +67,34 @@ class TagImplication < ActiveRecord::Base
|
||||
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 ParentMethods
|
||||
extend SearchMethods
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.user.id
|
||||
|
||||
@@ -42,6 +42,11 @@ class TagSubscription < ActiveRecord::Base
|
||||
user.is_moderator? || creator_id == user.id
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
end
|
||||
|
||||
def self.visible_to(user)
|
||||
where("(is_public = TRUE OR creator_id = ? OR ?)", user.id, user.is_moderator?)
|
||||
end
|
||||
|
||||
@@ -12,8 +12,6 @@ class Upload < ActiveRecord::Base
|
||||
before_create :convert_cgi_file
|
||||
after_destroy :delete_temp_file
|
||||
validate :uploader_is_not_limited
|
||||
scope :uploaded_by, lambda {|user_id| where(["uploader_id = ?", user_id])}
|
||||
scope :pending, where(:status => "pending")
|
||||
|
||||
module ValidationMethods
|
||||
def uploader_is_not_limited
|
||||
@@ -149,7 +147,8 @@ class Upload < ActiveRecord::Base
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
@@ -302,6 +301,31 @@ class Upload < ActiveRecord::Base
|
||||
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 ValidationMethods
|
||||
include FileMethods
|
||||
@@ -313,6 +337,7 @@ class Upload < ActiveRecord::Base
|
||||
include CgiFileMethods
|
||||
include StatusMethods
|
||||
include UploaderMethods
|
||||
extend SearchMethods
|
||||
|
||||
def presenter
|
||||
@presenter ||= UploadPresenter.new(self)
|
||||
|
||||
@@ -40,10 +40,6 @@ class User < ActiveRecord::Base
|
||||
has_many :note_versions, :foreign_key => "updater_id"
|
||||
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
||||
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
|
||||
def validate_ip_addr_is_not_banned
|
||||
@@ -417,6 +413,51 @@ class User < ActiveRecord::Base
|
||||
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 NameMethods
|
||||
include PasswordMethods
|
||||
@@ -429,6 +470,7 @@ class User < ActiveRecord::Base
|
||||
include LimitMethods
|
||||
include InvitationMethods
|
||||
include ApiMethods
|
||||
extend SearchMethods
|
||||
|
||||
def initialize_default_image_size
|
||||
self.default_image_size = "large"
|
||||
|
||||
@@ -6,11 +6,38 @@ class UserFeedback < ActiveRecord::Base
|
||||
attr_accessible :body, :user_id, :category, :user_name
|
||||
validates_presence_of :user, :creator, :body, :category
|
||||
validate :creator_is_privileged
|
||||
scope :positive, where("category = ?", "positive")
|
||||
scope :neutral, where("category = ?", "neutral")
|
||||
scope :negative, where("category = ?", "negative")
|
||||
scope :for_user, lambda {|user_id| where("user_id = ?", user_id)}
|
||||
|
||||
module SearchMethods
|
||||
def positive
|
||||
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
|
||||
self.creator_id = CurrentUser.id
|
||||
end
|
||||
|
||||
@@ -7,26 +7,37 @@ class WikiPage < ActiveRecord::Base
|
||||
validates_presence_of :title
|
||||
validate :validate_locker_is_janitor
|
||||
attr_accessible :title, :body, :is_locked
|
||||
scope :titled, lambda {|title| where(["title = ?", title.downcase.tr(" ", "_")])}
|
||||
scope :recent, order("updated_at DESC").limit(25)
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "title"
|
||||
has_one :artist, :foreign_key => "name", :primary_key => "title"
|
||||
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC"
|
||||
|
||||
def self.build_relation(options = {})
|
||||
relation = where()
|
||||
|
||||
if options[:title]
|
||||
relation = relation.where(["title LIKE ? ESCAPE E'\\\\'", options[:title].downcase.tr(" ", "_").to_escaped_for_sql_like])
|
||||
|
||||
module SearchMethods
|
||||
def titled(title)
|
||||
where("title = ?", title.downcase.tr(" ", "_"))
|
||||
end
|
||||
|
||||
if options[:creator_id]
|
||||
relation = relation.where(["creator_id = ?", options[:creator_id]])
|
||||
def recent
|
||||
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
|
||||
|
||||
relation
|
||||
end
|
||||
|
||||
extend SearchMethods
|
||||
|
||||
def self.find_title_and_id(title)
|
||||
titled(title).select("title, id").first
|
||||
end
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
class WikiPageVersion < ActiveRecord::Base
|
||||
belongs_to :wiki_page
|
||||
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
|
||||
User.id_to_name(updater_id)
|
||||
|
||||
@@ -70,27 +70,27 @@ class UserPresenter
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def inviter(template)
|
||||
@@ -110,7 +110,7 @@ class UserPresenter
|
||||
neutral = UserFeedback.for_user(user.id).neutral.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
|
||||
|
||||
def subscriptions(template)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<% if @artist && !@artist.new_record? %>
|
||||
<li>|</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>
|
||||
<% end %>
|
||||
</menu>
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
<h1>Search Artists</h1>
|
||||
|
||||
<div id="search-form">
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= f.input :name_contains, :label => "Name", :required => false %>
|
||||
<%= f.input :other_names_match, :label => "Other Names", :required => false %>
|
||||
<%= f.input :group_name_contains, :label => "Group Name", :required => false %>
|
||||
<%= f.input :url_match, :label => "URL", :required => false %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
<%= form_tag(artists_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "name" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
<div id="a-search">
|
||||
<h1>Search Comments</h1>
|
||||
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= form_tag(comments_path, :method => :get) do |f| %>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Received", dmails_path(:search => {:owner_id_eq => CurrentUser.id, :to_id_eq => 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 "Received", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></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 "Search", search_dmails_path %></li>
|
||||
</menu>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<div id="c-dmails">
|
||||
<div id="a-search">
|
||||
<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] %>
|
||||
<%= f.input :title_contains, :required => false, :label => "Title" %>
|
||||
<%= f.input :body_contains, :required => false, :label => "Body" %>
|
||||
<%= f.input :to_name_matches, :required => false, :label => "To" %>
|
||||
<%= f.input :from_name_matches, :required => false, :label => "From" %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
|
||||
<%= search_field :message_matches, :label => "Message" %>
|
||||
<%= search_field :to_name, :label => "To" %>
|
||||
<%= search_field :from_name, :label => "From" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<div id="c-forum-topics">
|
||||
<div id="a-search">
|
||||
<h1>Search Forum</h1>
|
||||
<%= simple_form_for @search do |f| %>
|
||||
<%= f.input :topic_title_matches, :label => "Title", :required => false %>
|
||||
<%= f.input :body_matches, :label => "Body", :required => false %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
<%= form_tag(forum_topics_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field :topic_title_matches, :label => "Title" %>
|
||||
<%= search_field :body_matches, :label => "Body" %>
|
||||
<%= search_field :creator_name, :label => "Author" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% @dashboard.artists.each do |activity| %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% @dashboard.notes.each do |activity| %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% @dashboard.tags.each do |activity| %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% @dashboard.wiki_pages.each do |activity| %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<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>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
@@ -10,7 +10,7 @@
|
||||
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<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>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
|
||||
@@ -2,18 +2,10 @@
|
||||
<div id="a-search">
|
||||
<h1>Search IP Addresses</h1>
|
||||
|
||||
<%= form_tag(moderator_ip_addrs_path) do %>
|
||||
<div class="input">
|
||||
<label>User</label>
|
||||
<%= text_field :search, :user_name %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label>IP Addr</label>
|
||||
<%= text_field :search, :ip_addr %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag %>
|
||||
<%= form_tag(moderator_ip_addrs_path, :class => "simple_form") do %>
|
||||
<%= search_field "user_name", :label => "User" %>
|
||||
<%= search_field "ip_addr", :label => "IP Addr" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<tr>
|
||||
<td></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>
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
<div id="a-search">
|
||||
<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" %>
|
||||
<%= f.input :body_matches, :label => "Body", :required => false %>
|
||||
<%= f.input :post_tag_match, :label => "Tags", :required => false %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
<%= search_field :body_matches, :label => "Body" %>
|
||||
<%= search_field :post_tags_match, :label => "Tags" %>
|
||||
<%= search_field :creator_name, :label => "Author" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</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>
|
||||
<% 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>
|
||||
<% end %>
|
||||
</menu>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<div id="c-pools">
|
||||
<div id="a-search">
|
||||
<%= simple_form_for @search, :method => :get do |f| %>
|
||||
<%= f.input :name_contains, :label => "Name", :required => false %>
|
||||
<%= f.input :description_contains, :label => "Description", :required => false %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
<%= form_tag pools_path, :method => :get, :class => "simple_form" do %>
|
||||
<%= search_field "name_matches", :label => "Name" %>
|
||||
<%= search_field "description_matches", :label => "Description" %>
|
||||
<%= search_field "creator_name", :label => "Creator" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<h1>Search Changes</h1>
|
||||
|
||||
<div id="search">
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= f.input :updater_name_matches, :label => "User", :required => false %>
|
||||
<%= f.input :post_id_eq, :label => "Post", :required => false %>
|
||||
<%= f.button :submit, :value => "Search" %>
|
||||
<%= form_tag(post_versions_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "updater_name", :label => "User" %>
|
||||
<%= search_field "post_id", :label => "Post" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
<section>
|
||||
<h1>History</h1>
|
||||
<ul>
|
||||
<li><%= link_to "Tags", post_versions_path(:search => {:post_id_eq => @post.id}) %></li>
|
||||
<li><%= link_to "Notes", note_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 => @post.id}) %></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<menu>
|
||||
<li><%= link_to "Listing", 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 %>
|
||||
<li>|</li>
|
||||
<li><%= link_to "Edit", edit_tag_path(@tag) %></li>
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
<div id="c-tags">
|
||||
<div id="a-search">
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= f.input :name_matches, :required => false, :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 %>
|
||||
<%= form_tag(tags_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "name_matches", :label => "Name" %>
|
||||
|
||||
<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" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<% end %>
|
||||
|
||||
<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? %>
|
||||
<%= link_to "Force update", upload_path(@upload, :format => "js"), :remote => true, :method => :put %>.
|
||||
<% end %>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<menu>
|
||||
<% if @user_feedback %>
|
||||
<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] %>
|
||||
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => params[:search][:user_id_eq]}) %></li>
|
||||
<% elsif params[:search] && params[:search][:user_id] %>
|
||||
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => params[:search][:user_id]}) %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "New", new_user_feedback_path %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% if @user.id == CurrentUser.id %>
|
||||
<li><%= link_to "Settings", edit_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 %>
|
||||
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
<div id="a-index">
|
||||
<h1>Users</h1>
|
||||
|
||||
<% simple_form_for(@search) do |f| %>
|
||||
<%= f.input :name_contains, :label => "Name" %>
|
||||
<%= f.sort_link "Name", :name %>
|
||||
<%= f.sort_link "Date", :created_at_desc %>
|
||||
<%= f.button :submit %>
|
||||
<% form_tag(users_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "name_matches", :label => "Name" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
|
||||
<table width="100%" class="striped">
|
||||
@@ -46,7 +44,7 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<% 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><span title="<%= user.created_at %>"><%= time_ago_in_words user.created_at %> ago</span></td>
|
||||
</tr>
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<div id="c-users">
|
||||
<div id="a-search">
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= f.input :name_matches, :required => false, :label => "Name" %>
|
||||
<%= f.button :submit, "Search" %>
|
||||
<%= form_tag(users_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "name_matches", :label => "Name" %>
|
||||
|
||||
<div class="input">
|
||||
<label for="search_level">Min Level</label>
|
||||
<%= select("search", "min_level", User.level_hash.to_a) %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<menu>
|
||||
<li><%= link_to "Listing", wiki_pages_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 %>
|
||||
<li>|</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? %>
|
||||
<% unless @wiki_page.new_record? %>
|
||||
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
|
||||
|
||||
Reference in New Issue
Block a user