From 0143401ac36b7d604b7dce4bf811e64cdf004d6d Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 20 Apr 2013 10:40:58 -0400 Subject: [PATCH] fixes #1332; partial fix for #1378 --- app/models/artist.rb | 20 ++++++++++++++++++++ app/models/artist_version.rb | 12 ++++++++++++ app/models/pool.rb | 6 ++++++ 3 files changed, 38 insertions(+) diff --git a/app/models/artist.rb b/app/models/artist.rb index cfefa5691..dcaefdc39 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -263,10 +263,30 @@ class Artist < ActiveRecord::Base q = q.reorder("id desc") end + if params[:is_active] == "true" + q = q.active + elsif params[:is_active] == "false" + q = q.where("is_active = false") + end + + if params[:is_banned] == "true" + q = q.banned + elsif params[:is_banned] == "false" + q = q.where("is_banned = false") + end + if params[:id].present? q = q.where("id = ?", params[:id]) end + if params[:creator_name].present? + q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].tr(" ", "_").mb_chars.downcase) + end + + if params[:creator_id].present? + q = q.where("creator_id = ?", params[:creator_id].to_i) + end + q end end diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index c0e1dc2f4..0be013811 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -29,6 +29,18 @@ class ArtistVersion < ActiveRecord::Base q = q.reorder("id desc") end + if params[:is_active] == "true" + q = q.where("is_active = true") + elsif params[:is_active] == "false" + q = q.where("is_active = false") + end + + if params[:is_banned] == "true" + q = q.where("is_banned = true") + elsif params[:is_banned] == "false" + q = q.where("is_banned = false") + end + q end end diff --git a/app/models/pool.rb b/app/models/pool.rb index 9983a70b6..04384b5c3 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -42,6 +42,12 @@ class Pool < ActiveRecord::Base q = q.where("creator_id = ?", params[:creator_id].to_i) end + if params[:is_active] == "true" + q = q.where("is_active = true") + elsif params[:is_active] == "false" + q = q.where("is_active = false") + end + if params[:sort] == "name" q = q.order("name") else