change privileged accounts to gold accounts, add platinum accounts, add favorite and tag query limiting based on level
This commit is contained in:
@@ -133,7 +133,19 @@ class AnonymousUser
|
||||
:anonymous
|
||||
end
|
||||
|
||||
%w(member banned privileged contributor janitor moderator admin).each do |name|
|
||||
def tag_query_limit
|
||||
2
|
||||
end
|
||||
|
||||
def favorite_limit
|
||||
0
|
||||
end
|
||||
|
||||
def favorite_count
|
||||
0
|
||||
end
|
||||
|
||||
%w(member banned privileged platinum contributor janitor moderator admin).each do |name|
|
||||
define_method("is_#{name}?") do
|
||||
false
|
||||
end
|
||||
|
||||
@@ -49,24 +49,24 @@ class PostQueryBuilder
|
||||
"''" + escaped_token + "''"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def add_tag_string_search_relation(tags, relation)
|
||||
tag_query_sql = []
|
||||
|
||||
if tags[:include].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time") if tags[:include].size > Danbooru.config.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.tag_query_limit} tags at a time") if tags[:include].size > CurrentUser.tag_query_limit
|
||||
tag_query_sql << "(" + escape_string_for_tsquery(tags[:include]).join(" | ") + ")"
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if tags[:related].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time") if tags[:related].size > Danbooru.config.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.tag_query_limit} tags at a time") if tags[:related].size > CurrentUser.tag_query_limit
|
||||
tag_query_sql << "(" + escape_string_for_tsquery(tags[:related]).join(" & ") + ")"
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if tags[:exclude].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time") if tags[:exclude].size > Danbooru.config.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.tag_query_limit} tags at a time") if tags[:exclude].size > CurrentUser.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for only excluded tags") unless has_constraints?
|
||||
|
||||
tag_query_sql << "!(" + escape_string_for_tsquery(tags[:exclude]).join(" | ") + ")"
|
||||
|
||||
Reference in New Issue
Block a user