diff --git a/Gemfile.lock b/Gemfile.lock index 4c782f67..6987e4ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,8 @@ GEM remote: https://rubygems.org/ specs: - RedCloth (4.2.9) + CFPropertyList (2.3.5) + RedCloth (4.3.2) actionmailer (3.2.19) actionpack (= 3.2.19) mail (~> 2.5.4) @@ -31,215 +32,318 @@ GEM multi_json (~> 1.0) acts-as-taggable-on (3.5.0) activerecord (>= 3.2, < 5) - acts_as_list (0.7.2) + acts_as_list (0.9.2) activerecord (>= 3.0) acts_as_xlsx (1.0.6) activerecord (>= 2.3.9) axlsx (>= 1.0.13) i18n (>= 0.4.1) - addressable (2.3.6) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) aes (0.5.0) - ansi (1.4.3) - apartment (0.26.0) - activerecord (>= 3.1.2, < 5.0) + ansi (1.5.0) + apartment (1.2.0) + activerecord (>= 3.1.2, < 6.0) rack (>= 1.3.6) - apartment-sidekiq (0.1.0) - apartment (>= 0.25) + apartment-sidekiq (1.1.0) + apartment (~> 1.0) sidekiq (>= 2.11) arel (3.0.3) - autonumeric-rails (1.9.43) + autonumeric-rails (2.0.0.1) jquery-rails (>= 2.0.2) - awesome_print (1.6.1) + awesome_print (1.7.0) aws (2.10.2) http_connection uuidtools xml-simple - axlsx (1.3.6) + axlsx (2.0.1) htmlentities (~> 4.3.1) nokogiri (>= 1.4.1) - rubyzip (>= 0.9.5) + rubyzip (~> 1.0.0) bcrypt-ruby (3.0.1) builder (3.0.4) - byebug (3.5.1) - columnize (~> 0.8) - debugger-linecache (~> 1.2) - slop (~> 3.6) - carrierwave (0.10.0) + byebug (9.0.6) + carrierwave (0.11.2) activemodel (>= 3.2.0) activesupport (>= 3.2.0) json (>= 1.7) mime-types (>= 1.16) - celluloid (0.16.0) - timers (~> 4.0.0) - coderay (1.1.0) + mimemagic (>= 0.3.0) + celluloid (0.17.3) + celluloid-essentials + celluloid-extras + celluloid-fsm + celluloid-pool + celluloid-supervision + timers (>= 4.1.1) + celluloid-essentials (0.20.5) + timers (>= 4.1.1) + celluloid-extras (0.20.5) + timers (>= 4.1.1) + celluloid-fsm (0.20.5) + timers (>= 4.1.1) + celluloid-pool (0.20.5) + timers (>= 4.1.1) + celluloid-supervision (0.20.6) + timers (>= 4.1.1) + coderay (1.1.1) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) - coffee-script (2.3.0) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.8.0) - columnize (0.8.9) - connection_pool (2.1.0) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.4) + connection_pool (2.2.1) countries (0.9.3) currencies (~> 0.4.2) country_select (1.3.1) countries (= 0.9.3) currencies (0.4.2) - debugger-linecache (1.2.0) erubis (2.7.0) - excon (0.40.0) - execjs (2.2.2) + excon (0.55.0) + execjs (2.7.0) ey_config (0.0.7) - fabrication (2.14.0) - faker (1.4.3) + fabrication (2.16.0) + faker (1.7.3) i18n (~> 0.5) - faraday (0.9.0) + faraday (0.10.1) multipart-post (>= 1.2, < 3) - fast_stack (0.1.0) - rake - rake-compiler fastercsv (1.5.5) - flamegraph (0.1.0) - fast_stack - fog (1.24.0) - fog-brightbox - fog-core (~> 1.23) + fission (0.5.0) + CFPropertyList (~> 2.2) + flamegraph (0.9.5) + fog (1.38.0) + fog-aliyun (>= 0.1.0) + fog-atmos + fog-aws (>= 0.6.0) + fog-brightbox (~> 0.4) + fog-cloudatcost (~> 0.1.0) + fog-core (~> 1.32) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (<= 0.1.0) fog-json + fog-local + fog-openstack + fog-powerdns (>= 0.1.1) + fog-profitbricks + fog-rackspace fog-radosgw (>= 0.0.2) + fog-riakcs fog-sakuracloud (>= 0.0.4) + fog-serverlove fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-vsphere (>= 0.4.0) + fog-xenserver + fog-xml (~> 0.1.1) ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-brightbox (0.6.1) + fog-aliyun (0.1.0) + fog-core (~> 1.27) + fog-json (~> 1.0) + ipaddress (~> 0.8) + xml-simple (~> 1.1) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (1.2.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.11.0) fog-core (~> 1.22) fog-json - inflecto - fog-core (1.24.0) + inflecto (~> 0.0.2) + fog-cloudatcost (0.1.2) + fog-core (~> 1.36) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.43.0) builder - excon (~> 0.38) + excon (~> 0.49) formatador (~> 0.2) - mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - fog-json (1.0.0) - multi_json (~> 1.0) - fog-radosgw (0.0.3) + fog-dynect (0.0.3) + fog-core + fog-json + fog-xml + fog-ecloud (0.3.0) + fog-core + fog-xml + fog-google (0.1.0) + fog-core + fog-json + fog-xml + fog-json (1.0.2) + fog-core (~> 1.0) + multi_json (~> 1.10) + fog-local (0.3.1) + fog-core (~> 1.27) + fog-openstack (0.1.20) + fog-core (>= 1.40) + fog-json (>= 1.0) + ipaddress (>= 0.8) + fog-powerdns (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + fog-profitbricks (3.0.0) + fog-core (~> 1.42) + fog-json (~> 1.0) + fog-rackspace (0.1.4) + fog-core (>= 1.35) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.8) + fog-radosgw (0.0.5) fog-core (>= 1.21.0) fog-json fog-xml (>= 0.0.1) - fog-sakuracloud (0.1.1) + fog-riakcs (0.1.0) fog-core fog-json - fog-softlayer (0.3.22) + fog-xml + fog-sakuracloud (1.7.5) fog-core fog-json - fog-xml (0.1.0) + fog-serverlove (0.1.2) + fog-core + fog-json + fog-softlayer (1.1.4) + fog-core + fog-json + fog-storm_on_demand (0.1.1) + fog-core + fog-json + fog-terremark (0.1.0) + fog-core + fog-xml + fog-vmfusion (0.1.0) + fission + fog-core + fog-voxel (0.1.0) + fog-core + fog-xml + fog-vsphere (1.2.1) + fog-core + rbvmomi (~> 1.8.0) + fog-xenserver (0.2.3) + fog-core + fog-xml + fog-xml (0.1.2) fog-core nokogiri (~> 1.5, >= 1.5.11) formatador (0.2.5) - formtastic (3.0.0) + formtastic (3.1.5) actionpack (>= 3.2.13) friendly_id (4.0.10.1) activerecord (>= 3.0, < 4.0) - geocoder (1.2.5) - hashie (3.3.1) + geocoder (1.4.3) + hashie (3.5.5) hike (1.2.3) - hitimes (1.2.2) - htmlentities (4.3.2) + hitimes (1.2.4) + htmlentities (4.3.4) http_connection (1.4.4) i18n (0.7.0) inflecto (0.0.2) - ipaddress (0.8.0) + ipaddress (0.8.3) journey (1.0.4) - jquery-rails (3.1.2) + jquery-rails (3.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-tablesorter (1.15.0) - railties (>= 3.2, < 5) - jquery-ui-rails (5.0.2) + jquery-tablesorter (1.23.5) + railties (>= 3.2, < 6) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (1.8.1) - jwt (1.0.0) - kgio (2.9.2) - le (2.6.2) + json (1.8.6) + jwt (1.5.6) + kgio (2.11.0) + le (2.7.5) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mandrill-api (1.0.53) excon (>= 0.16.0, < 1.0) json (>= 1.7.7, < 2.0) - memory_profiler (0.9.6) + memory_profiler (0.9.7) mime-types (1.25.1) - mini_magick (4.2.0) - mini_portile (0.6.0) + mimemagic (0.3.2) + mini_magick (4.6.1) + mini_portile2 (2.1.0) minitest (4.7.5) - monetize (1.4.0) - money (~> 6.7) - money (6.7.1) + monetize (1.6.0) + money (~> 6.8) + money (6.8.1) i18n (>= 0.6.4, <= 0.7.0) sixarm_ruby_unaccent (>= 1.1.1, < 2) - money-rails (1.6.1) + money-rails (1.8.0) activesupport (>= 3.0) - monetize (~> 1.4.0) - money (~> 6.7) + monetize (~> 1.6.0) + money (~> 6.8.1) railties (>= 3.0) - multi_json (1.10.1) - multi_xml (0.5.5) + multi_json (1.12.1) + multi_xml (0.6.0) multipart-post (2.0.0) - mysql2 (0.3.16) - net-scp (1.2.1) - net-ssh (>= 2.6.5) + mysql2 (0.3.21) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (2.9.1) - nokogiri (1.6.3.1) - mini_portile (= 0.6.0) - oauth (0.4.7) - oauth2 (1.0.0) - faraday (>= 0.8, < 0.10) + net-ssh (4.1.0) + nokogiri (1.7.0.1) + mini_portile2 (~> 2.1.0) + oauth (0.5.1) + oauth2 (1.3.0) + faraday (>= 0.8, < 0.11) jwt (~> 1.0) multi_json (~> 1.3) multi_xml (~> 0.5) - rack (~> 1.2) - omniauth (1.2.2) + rack (>= 1.2, < 3) + omniauth (1.4.2) hashie (>= 1.2, < 4) - rack (~> 1.0) - omniauth-facebook (2.0.0) + rack (>= 1.0, < 3) + omniauth-facebook (4.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (0.2.5) - omniauth (> 1.0) - omniauth-oauth2 (~> 1.1) + omniauth-google-oauth2 (0.4.1) + jwt (~> 1.5.2) + multi_json (~> 1.3) + omniauth (>= 1.1.1) + omniauth-oauth2 (>= 1.3.1) omniauth-identity (1.1.1) bcrypt-ruby (~> 3.0) omniauth (~> 1.0) omniauth-linkedin (0.2.0) omniauth-oauth (~> 1.0) - omniauth-oauth (1.0.1) + omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) - omniauth-oauth2 (1.2.0) - faraday (>= 0.8, < 0.10) - multi_json (~> 1.3) + omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) - omniauth-shibboleth (1.1.2) + omniauth-shibboleth (1.2.1) omniauth (>= 1.0.0) - omniauth-twitter (1.1.0) - multi_json (~> 1.3) - omniauth-oauth (~> 1.0) - omniauth-windowslive (0.0.9) - multi_json (>= 1.0.3) - omniauth-oauth2 (~> 1.0) + omniauth-twitter (1.4.0) + omniauth-oauth (~> 1.1) + rack + omniauth-windowslive (0.0.12) + multi_json (~> 1.12) + omniauth-oauth2 (~> 1.4) polyglot (0.3.5) - rack (1.4.5) - rack-cache (1.2) + public_suffix (2.0.5) + rack (1.4.7) + rack-cache (1.7.0) rack (>= 0.4) - rack-mini-profiler (0.9.7) - rack (>= 1.1.3) + rack-mini-profiler (0.10.2) + rack (>= 1.2.0) + rack-protection (1.5.3) + rack rack-ssl (1.3.4) rack - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) rails (3.2.19) actionmailer (= 3.2.19) @@ -249,8 +353,8 @@ GEM activesupport (= 3.2.19) bundler (~> 1.0) railties (= 3.2.19) - rails3-jquery-autocomplete (1.0.14) - rails (>= 3.0) + rails3-jquery-autocomplete (1.0.15) + rails (>= 3.2) rails_autolink (1.0.9) rails (~> 3.1) railties (3.2.19) @@ -260,68 +364,65 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - raindrops (0.13.0) - rake (10.3.2) - rake-compiler (0.9.5) - rake + raindrops (0.17.0) + rake (12.0.0) + rbvmomi (1.8.2) + builder + nokogiri (>= 1.4.1) + trollop rdoc (3.12.2) json (~> 1.4) - redis (3.2.0) - redis-namespace (1.5.1) - redis (~> 3.0, >= 3.0.4) - rollbar (1.4.4) - multi_json (~> 1.3) - rubyzip (1.1.6) - sass (3.4.6) + redis (3.3.3) + rollbar (2.14.0) + multi_json + rubyzip (1.0.0) + sass (3.4.23) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - select2-rails (4.0.1.1) + select2-rails (4.0.3) thor (~> 0.14) - sidekiq (3.3.0) - celluloid (>= 0.16.0) - connection_pool (>= 2.0.0) - json - redis (>= 3.0.6) - redis-namespace (>= 1.3.1) - simple_calendar (1.1.9) + sidekiq (4.2.9) + concurrent-ruby (~> 1.0) + connection_pool (~> 2.2, >= 2.2.0) + rack-protection (>= 1.5.0) + redis (~> 3.2, >= 3.2.1) + simple_calendar (1.1.10) rails (>= 3.0) sixarm_ruby_unaccent (1.1.1) - slop (3.6.0) - sprockets (2.2.2) + sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.9) - stackprof (0.2.7) - sucker_punch (1.3.1) - celluloid (~> 0.16.0) - thor (0.19.1) + sqlite3 (1.3.13) + stackprof (0.2.10) + sucker_punch (1.6.0) + celluloid (~> 0.17.2) + thor (0.19.4) tilt (1.4.1) - timers (4.0.1) + timers (4.1.2) hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) + trollop (2.1.2) turn (0.9.7) ansi minitest (~> 4) - tzinfo (0.3.42) - uglifier (2.5.3) - execjs (>= 0.3.0) - json (>= 1.8.0) - unicorn (4.8.3) + tzinfo (0.3.52) + uglifier (3.0.4) + execjs (>= 0.3.0, < 3) + unicorn (5.2.0) kgio (~> 2.6) - rack raindrops (~> 0.7) - unicorn-rails (2.2.0) + unicorn-rails (2.2.1) rack unicorn uuidtools (2.1.5) - will_paginate (3.0.7) - xml-simple (1.1.4) + will_paginate (3.1.5) + xml-simple (1.1.5) zip (2.0.2) PLATFORMS @@ -395,3 +496,6 @@ DEPENDENCIES unicorn-rails will_paginate (~> 3.0) zip + +BUNDLED WITH + 1.11.2 diff --git a/app/controllers/mentors_controller.rb b/app/controllers/mentors_controller.rb index 5fc9dfce..da10eabe 100644 --- a/app/controllers/mentors_controller.rb +++ b/app/controllers/mentors_controller.rb @@ -145,12 +145,19 @@ def photo end def auto_complete_for_mentor_fullname - @mentors = Mentor.find(:all, - :conditions => ["firstname LIKE :fullname - OR lastname LIKE :fullname - OR display_name LIKE :fullname - OR uw_net_id LIKE :fullname", - {:fullname => "%#{params[:term].downcase}%"}]) + generated_conditions = Mentor.find_by_name(params[:term]) + conditions = generated_conditions[0] + first = generated_conditions[1] + middle = generated_conditions[2] + last = generated_conditions[3] + + @mentors = Mentor.find(:all, + :conditions => [conditions, + { + :firstname => "%#{first}", + :lastname => "%#{last}", + :middlename => "%#{middle}" + }]) render :json => @mentors.map { |mentor| { diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index e4108c2a..3cd86639 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -365,14 +365,21 @@ def fetch_participant_group_options def auto_complete_for_participant_fullname if params[:term].to_i != 0 @participants = [ Participant.find(params[:term].to_i) ] - else - conditions = ["(firstname LIKE :fullname OR lastname LIKE :fullname)"] + else + generated_conditions = Participant.find_by_name(params[:term]) + conditions = generated_conditions[0] + first = generated_conditions[1] + middle = generated_conditions[2] + last = generated_conditions[3] + conditions << "high_school_id = :high_school_id" if params[:high_school_id] conditions << "grad_year = :grad_year" if params[:grad_year] @participants = Participant.find(:all, - :conditions => [conditions.join(" AND "), - {:fullname => "%#{params[:term].downcase}%", + :conditions => [conditions, + {:firstname => "%#{first}", + :lastname => "%#{last}", + :middlename => "%#{middle}", :grad_year => params[:grad_year], :high_school_id => params[:high_school_id] }]) diff --git a/app/models/people/person.rb b/app/models/people/person.rb index 7ba2332f..a4821c96 100644 --- a/app/models/people/person.rb +++ b/app/models/people/person.rb @@ -131,6 +131,51 @@ def self.object_filters [] end + def self.find_by_name(name) + name = name.downcase + args = name.split(" ") + conditions = generate_conditions(args, name) + return conditions + end + + def self.generate_conditions(args, name) + len = args.length + first = "" + middle = "" + last = "" + args = args.each { |s| s.strip! } + conditions = "" + + if (len == 1) + first = middle = last = name + conditions = ["(LOWER(firstname) LIKE :firstname OR LOWER(lastname) LIKE :lastname)", first, middle, last] + elsif (len == 2) + if(args[0].end_with? ",") + # Results for L, F ordering + last = args[0][0..args[0].length - 2] + first = args[1] + else + # Results for F M or F L + first = args[0] + last = args[1] + middle = args[1] + end + conditions = ["(LOWER(firstname) LIKE :firstname AND(LOWER(lastname) LIKE :lastname OR LOWER(middlename) LIKE :middlename))", first, middle, last] + else + if(args[0].end_with? ",") + last = args[0][0..args[0].length - 2] + first = args[1] + middle = args[2] + else + last = args[2] + first = args[0] + middle = args[1] + end + conditions = ["(LOWER(firstname) LIKE :firstname AND LOWER(lastname) LIKE :lastname AND LOWER(middlename) LIKE :middlename)", first, middle, last] + end + return conditions + end + # Updates the filter cache by checking each ObjectFilter, and then saves the current record # by calling +update_attribute+ so that +updated_at+ is not modified. def update_filter_cache_and_save! diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c4f2c231..0f4dcc3f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -136,7 +136,7 @@