From 624f2c704bb97a39f7c1f5947990e1a7dda377ff Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 14 Jun 2014 14:17:06 -0400 Subject: [PATCH] Add wiki search option for whether other names are present --- app/models/wiki_page.rb | 6 ++++++ app/views/wiki_pages/search.html.erb | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index c022d0eed..49baa181a 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -63,6 +63,12 @@ class WikiPage < ActiveRecord::Base q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].tr(" ", "_").mb_chars.downcase) end + if params[:other_names_present] == "yes" + q = q.where("other_names is not null and other_names != ''") + elsif params[:other_names_present] == "no" + q = q.where("other_names is null or other_names = ''") + end + params[:order] ||= params.delete(:sort) if params[:order] == "time" || params[:order] == "Date" q = q.order("updated_at desc") diff --git a/app/views/wiki_pages/search.html.erb b/app/views/wiki_pages/search.html.erb index 9d102c7d4..92c951eca 100644 --- a/app/views/wiki_pages/search.html.erb +++ b/app/views/wiki_pages/search.html.erb @@ -6,6 +6,11 @@ <%= search_field "body_matches", :label => "Body" %> <%= search_field "other_names_match", :label => "Other names" %> +
+ + <%= select "search", "other_names_present", ["yes", "no"], :include_blank => true %> +
+
<%= select "search", "order", ["Name", "Date"] %>