Sha256: 03d17a7c3039825407e808499580ec443ca71d248f2a7e7d5dfc3666e93beab0

Contents?: true

Size: 1.53 KB

Versions: 68

Compression:

Stored size: 1.53 KB

Contents

##
## Campaigns send individual contexts to leads.
##
class ::IshManager::EmailCampaignsController < IshManager::ApplicationController

  before_action :set_lists

  def create
    @campaign = Ish::EmailCampaign.new params[:campaign].permit!
    authorize! :create, @campaign
    if @campaign.save
      flash[:notice] = "created campaign"
    else
      flash[:alert] = "Cannot create campaign: #{@campaign.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def do_send
    @campaign = Ish::EmailCampaign.find params[:id]
    authorize! :send, @campaign
    @campaign.do_send
  end

  def edit
    @campaign = Ish::EmailCampaign.find params[:id]
    authorize! :edit, @campaign
  end

  def index
    authorize! :index, Ish::EmailCampaign
    @campaigns = Ish::EmailCampaign.all
  end

  def new
    @campaign = Ish::EmailCampaign.new
    authorize! :new, @campaign
  end

  def show
    @campaign = Ish::EmailCampaign.find params[:id]
    authorize! :show, @campaign
    @leads = @campaign.leads
    if params[:q].present?
      @leads = @leads.where(" email LIKE ? ", "%#{params[:q]}%" )
    end
    @leads = @leads.page( params[:leads_page ] ).per( current_profile.per_page )
  end

  def update
    @campaign = Ish::EmailCampaign.find params[:id]
    authorize! :update, @campaign
    if @campaign.update_attributes params[:campaign].permit!
      flash[:notice] = 'Successfully updated campaign.'
    else
      flash[:alert] = "Cannot update campaign: #{@campaign.errors.messages}"
    end
    redirect_to :action => 'index'
  end

end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
ish_manager-0.1.8.513 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.512 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.511 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.510 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.509 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.508 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.507 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.506 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.505 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.504 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.503 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.500 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.499 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.498 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.497 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.496 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.495 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.494 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.493 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.492 app/controllers/ish_manager/email_campaigns_controller.rb