app/controllers/searches_controller.rb in artfully_ose-1.2.0.beta.1 vs app/controllers/searches_controller.rb in artfully_ose-1.2.0.pre

- old
+ new

@@ -4,13 +4,12 @@ before_filter :load_tags, :only => [:new, :show] def new authorize! :view, Search @search = Search.new(params[:search]) - @membership_types = current_user.current_organization.membership_types.all - @pass_types = current_user.current_organization.pass_types.all - prepare_form + @membership_types = MembershipType.all + prepare_search_and_people end def create authorize! :create, Search @search = Search.new(params[:search]) @@ -21,19 +20,17 @@ def show @search = Search.find(params[:id]) authorize! :view, @search @segment = Segment.new - @membership_types = current_user.current_organization.membership_types.all - @pass_types = current_user.current_organization.pass_types.all + @membership_types = MembershipType.all session[:return_to] ||= request.referer # Record the current page, in case creating a list segment fails. - prepare_form - prepare_people + prepare_search_and_people respond_to do |format| - format.html { @people = @people.paginate(:page => params[:page], :per_page => (params[:per_page] || 20)) } - format.csv { render :csv => Person.where(:id => @people.collect(&:id)).includes(:phones, :address, :tags).order('lower(people.last_name)'), :filename => "#{@search.id}-#{DateTime.now.strftime("%m-%d-%y")}" } - end + format.html + format.csv { render :csv => @search.people, :filename => "#{@search.id}-#{DateTime.now.strftime("%m-%d-%y")}" } + end end def tag @search = Search.find(params[:id]) authorize! :tag, Segment @@ -42,16 +39,13 @@ redirect_to @search end private - def prepare_form + def prepare_search_and_people @event_options = Event.options_for_select_by_organization(@current_user.current_organization) - @event_options.unshift(["Any Event", Search::ANY_EVENT]) - end - - def prepare_people @people = @search.people + @people = @people.paginate(:page => params[:page], :per_page => 20) end def load_discount_codes @discount_codes = Discount.where(:organization_id => current_user.current_organization).all.map(&:code) @discount_codes << Discount::ALL_DISCOUNTS_STRING