Commit d83dd4b0 authored by Mario Manno's avatar Mario Manno

Merge branch 'search'

parents dad7308c b3bd8c92
......@@ -7,7 +7,6 @@ gem 'pg', group: :postgresql
gem 'sqlite3', group: :sqlite3
gem 'acts_as_commentable'
gem 'acts_as_indexed'
gem 'barista'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'cancancan'
......
......@@ -54,7 +54,6 @@ GEM
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
acts_as_commentable (4.0.1)
acts_as_indexed (0.8.3)
ansi (1.4.3)
arel (3.0.3)
barista (1.3.0)
......@@ -228,7 +227,6 @@ PLATFORMS
DEPENDENCIES
acts_as_commentable
acts_as_indexed
barista
bcrypt-ruby (~> 3.0.0)
bullet
......
......@@ -10,12 +10,8 @@ class ConferencesController < ApplicationController
# GET /conferences
# GET /conferences.xml
def index
if params.has_key?(:term) and not params[:term].empty?
@search = Conference.with_query(params[:term]).search(params[:q])
else
@search = Conference.search(params[:q])
end
@conferences = @search.result.paginate page: page_param
result = search Conference, params
@conferences = result.paginate page: page_param
respond_to do |format|
format.html # index.html.erb
......@@ -100,6 +96,21 @@ class ConferencesController < ApplicationController
return "edit"
end
def search(conferences, params)
if params.has_key?(:term) and not params[:term].empty?
term = params[:term]
sort = params[:q][:s] rescue nil
@search = events.ransack(title_cont: term,
acronym_cont: term,
m: 'or',
s: sort)
else
@search = conferences.ransack(params[:q])
end
@search.result(distinct: true)
end
def conference_params
params.require(:conference).permit(
:acronym, :title, :timezone, :timeslot_duration, :default_timeslots, :max_timeslots, :feedback_enabled, :email, :program_export_base_url, :schedule_version, :schedule_public, :color, :ticket_type, :event_state_visible, :schedule_custom_css, :schedule_html_intro, :default_recording_license,
......
......@@ -8,12 +8,9 @@ class EventsController < ApplicationController
# GET /events.xml
def index
authorize! :read, Event
if params.has_key?(:term) and not params[:term].empty?
@search = @conference.events.with_query(params[:term]).includes(:track).search(params[:q])
else
@search = @conference.events.includes(:track).search(params[:q])
end
@events = @search.result.paginate page: page_param
result = search @conference.events.includes(:track), params
@events = result.paginate page: page_param
clean_events_attributes
respond_to do |format|
......@@ -25,13 +22,10 @@ class EventsController < ApplicationController
# current_users events
def my
authorize! :read, Event
if params.has_key?(:term) and not params[:term].empty?
@search = @conference.events.associated_with(current_user.person).with_query(params[:term]).search(params[:q])
else
@search = @conference.events.associated_with(current_user.person).search(params[:q])
end
result = search @conference.events.associated_with(current_user.person), params
clean_events_attributes
@events = @search.result.paginate page: page_param
@events = result.paginate page: page_param
end
# events as pdf
......@@ -51,8 +45,9 @@ class EventsController < ApplicationController
# show event ratings
def ratings
authorize! :create, EventRating
@search = @conference.events.search(params[:q])
@events = @search.result.paginate page: page_param
result = search @conference.events, params
@events = result.paginate page: page_param
clean_events_attributes
# total ratings:
......@@ -68,8 +63,8 @@ class EventsController < ApplicationController
# show event feedbacks
def feedbacks
authorize! :access, :event_feedback
@search = @conference.events.accepted.search(params[:q])
@events = @search.result.paginate page: page_param
result = search @conference.events.accepted, params
@events = result.paginate page: page_param
end
# start batch event review
......@@ -223,6 +218,24 @@ class EventsController < ApplicationController
end
end
def search(events, params)
if params.has_key?(:term) and not params[:term].empty?
term = params[:term]
sort = params[:q][:s] rescue nil
@search = events.ransack(title_cont: term,
description_cont: term,
abstract_cont: term,
track_name_cont: term,
event_type_is: term,
m: 'or',
s: sort)
else
@search = events.ransack(params[:q])
end
@search.result(distinct: true)
end
def event_params
params.require(:event).permit(
:id, :title, :subtitle, :event_type, :time_slots, :state, :start_time, :public, :language, :abstract, :description, :logo, :track_id, :room_id, :note, :submission_note, :do_not_record, :recording_license,
......
......@@ -8,12 +8,8 @@ class PeopleController < ApplicationController
# GET /people.xml
def index
authorize! :administrate, Person
if params.has_key?(:term) and not params[:term].empty?
@search = Person.involved_in(@conference).with_query(params[:term]).search(params[:q])
else
@search = Person.involved_in(@conference).search(params[:q])
end
@people = @search.result.paginate page: page_param
result = search Person.involved_in(@conference), params
@people = result.paginate page: page_param
end
def speakers
......@@ -22,12 +18,8 @@ class PeopleController < ApplicationController
respond_to do |format|
format.html do
if params.has_key?(:term) and not params[:term].empty?
@search = @people.involved_in(@conference).with_query(params[:term]).search(params[:q])
else
@search = @people.involved_in(@conference).search(params[:q])
end
@people = @search.result.paginate page: page_param
result = search Person.involved_in(@conference), params
@people = result.paginate page: page_param
end
format.text do
render text: @people.map(&:email).join("\n")
......@@ -37,12 +29,8 @@ class PeopleController < ApplicationController
def all
authorize! :administrate, Person
if params.has_key?(:term) and not params[:term].empty?
@search = Person.with_query(params[:term]).search(params[:q])
else
@search = Person.search(params[:q])
end
@people = @search.result.paginate page: page_param
result = search Person, params
@people = result.paginate page: page_param
end
# GET /people/1
......@@ -154,6 +142,26 @@ class PeopleController < ApplicationController
end
end
def search(people, params)
if params.has_key?(:term) and not params[:term].empty?
term = params[:term]
sort = params[:q][:s] rescue nil
@search = people.ransack(first_name_cont: term,
last_name_cont: term,
public_name_cont: term,
email_cont: term,
abstract_cont: term,
description_cont: term,
user_email_cont: term,
m: 'or',
s: sort)
else
@search = people.ransack(params[:q])
end
@search.result(distinct: true)
end
def person_params
params.require(:person).permit(
:first_name, :last_name, :public_name, :email, :email_public, :gender, :avatar_file_name, :abstract, :description, :include_in_mailings, :note,
......
......@@ -13,8 +13,6 @@ class Conference < ActiveRecord::Base
has_one :call_for_papers, dependent: :destroy
has_one :ticket_server, dependent: :destroy
acts_as_indexed fields: [:title, :acronym ]
accepts_nested_attributes_for :rooms, reject_if: proc {|r| r["name"].blank?}, allow_destroy: true
accepts_nested_attributes_for :days, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :tracks, reject_if: :all_blank, allow_destroy: true
......
......@@ -48,9 +48,7 @@ class Event < ActiveRecord::Base
scope :without_speaker, where("speaker_count = 0")
scope :with_speaker, where("speaker_count > 0")
acts_as_indexed fields: [:title, :subtitle, :event_type, :abstract, :description, :track_name]
has_paper_trail
has_paper_trail
state_machine do
state :new
......
......@@ -21,8 +21,6 @@ class Person < ActiveRecord::Base
before_save :nilify_empty
acts_as_indexed fields: [:first_name, :last_name, :public_name, :email, :abstract, :description, :user_email]
has_paper_trail
has_attached_file :avatar,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment