app/controllers/events_controller.rb in artfully_ose-1.2.0.pre.23 vs app/controllers/events_controller.rb in artfully_ose-1.2.0.pre.24

- old
+ new

@@ -1,7 +1,7 @@ class EventsController < ArtfullyOseController - respond_to :html, :json + respond_to :html, :json, :js before_filter :find_event, :only => [ :show, :edit, :update, :destroy, :widget, :image, :storefront_link, :prices, :messages, :resell, :wp_plugin, :passes ] before_filter :upcoming_shows, :only => :show before_filter { authorize! :view, @event if @event } @@ -21,10 +21,19 @@ end end def index authorize! :view, Event - @events = current_organization.events.includes(:shows, :tickets).order('updated_at DESC') + + scope = Event.unscoped.where(:deleted_at => nil).where(:organization_id => current_organization.id).includes(:shows).order('name ASC') + scope = if params[:range].present? && params[:range] == 'all' + @all = scope + else + @upcoming = scope.where :id => current_organization.shows.unplayed.pluck(:event_id).uniq + end + + scope = scope.where('LOWER(name) LIKE ?', "%#{params[:query].downcase}%") unless params[:query].blank? + @events = scope end def show authorize! :view, @event @shows = @event.shows.paginate(:page => params[:page], :per_page => 25)