Sha256: 3d5f0909252c113cd561f69dec60b951270c79c6573048d1a65910f870efc896

Contents?: true

Size: 1.54 KB

Versions: 11

Compression:

Stored size: 1.54 KB

Contents

class PassesController < ArtfullyOseController
  before_filter :find_person
  before_filter :load_tags, :only => [:index]

  def index
    @passes = @person.passes.includes(:pass_type, :tickets).not_expired
    @expired_passes = @person.passes.includes(:pass_type).expired
  end

  def bulk_update
    @person = Person.find(params[:person_id])
    authorize! :edit, @person
    extend_passes(params)
    redirect_to person_passes_path(@person)
  end

  def reminder
    @person = Person.find(params[:person_id])
    authorize! :edit, @person
    @pass_ids = params['pass_ids']

    if @pass_ids.blank?
      flash[:error] = "Please select at least one pass to send a reminder for."
    else
      @passes = Pass.where(:organization_id => @person.organization.id)
                    .where(:id => params[:pass_ids])
                    .all
      @person.delay.send_pass_summary_email(@passes)
      flash[:notice] = "We'll get those pass codes out to #{@person} right away!"
    end

    redirect_to person_passes_path(@person)
  end

  private
    def find_person
      @person = current_organization.people.find(params[:person_id])
    end

    def extend_passes(params)  
      if params[:commit].eql? "Change Expiration"
        if params[:pass_ids].blank?
          flash[:error] = "Please select at least one pass to send a reminder for."
        else
          params[:pass_ids].each do |pass_id|
            Pass.find(pass_id).adjust_expiration_to(params[:ends_at])
          end
          flash[:notice] = "Passes have been adjusted."
        end
      end
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/controllers/passes_controller.rb
artfully_ose-1.3.0.pre3 app/controllers/passes_controller.rb
artfully_ose-1.3.0.pre2 app/controllers/passes_controller.rb
artfully_ose-1.3.0.pre1 app/controllers/passes_controller.rb
artfully_ose-1.2.0 app/controllers/passes_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/passes_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/passes_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/passes_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/passes_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/passes_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/passes_controller.rb