Sha256: 5740896938be61c79fadfcf4f29ccdffa9cdf2d510ff4c0bf583d14938ade028

Contents?: true

Size: 1.63 KB

Versions: 83

Compression:

Stored size: 1.63 KB

Contents

EmailCampaign = WcoEmail::Campaign

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

  before_action :set_lists

  def create
    @campaign = 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 = EmailCampaign.find params[:id]
    authorize! :send, @campaign
    @campaign.do_send
  end

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

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

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

  def show
    @campaign = 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 = 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

  ##
  ## private
  ##
  private

  def set_lists
    @email_templates_list = WcoEmail::EmailTemplate.list
  end

end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
wco_email-0.1.1.86 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.85 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.84 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.83 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.82 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.81 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.80 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.79 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.78 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.77 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.76 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.75 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.72 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.71 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.70 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.69 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.68 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.67 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.66 app/controllers/wco_email/email_campaigns_controller.rb
wco_email-0.1.1.65 app/controllers/wco_email/email_campaigns_controller.rb