Sha256: 074e9ffbe81eec3b5d4bd9ecd0a8b4588b6819002334a161366d50f7915f7cbe

Contents?: true

Size: 1.74 KB

Versions: 51

Compression:

Stored size: 1.74 KB

Contents

class ::IshManager::EmailCampaignsController < IshManager::ApplicationController

  def do_send

    # case @ctx.type
    # when ::Ish::EmailContext::TYPE_SINGLE
    #   flash[:notice] = 'Scheduled a single send - v2'
    #   @ctx.send_at = Time.now
    #   @ctx.save
    # when ::Ish::EmailContext::TYPE_CAMPAIGN
    #   flash[:notice] = 'Scheduled campaign send'
    #   IshManager::EmailCampaignJob.new.perform(params[:id])
    # end
  end

  def index
    authorize! :index, Ish::EmailCampaign
    @campaigns = Ish::EmailCampaign.where( :profile => @current_profile, :is_trash => false )
    if params[:is_done]
      @campaigns = @campaigns.where( :is_done => true )
    else
      @campaigns = @campaigns.where( :is_done => false )
    end
  end

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

  def create
    @campaign = Ish::EmailCampaign.new params[:campaign].permit!
    @campaign.profile = @current_profile
    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 show
    authorize! :redirect, IshManager::Ability
    redirect_to :action => :edit, :id => params[:id]
  end

  def edit
    @campaign = Ish::EmailCampaign.find params[:id]
    authorize! :edit, @campaign
  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

51 entries across 51 versions & 1 rubygems

Version Path
ish_manager-0.1.8.366 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.365 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.364 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.363 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.362 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.361 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.360 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.359 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.358 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.357 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.356 app/controllers/ish_manager/email_campaigns_controller.rb