Class: AlchemyCrm::Admin::DeliveriesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/alchemy_crm/admin/deliveries_controller.rb

Instance Method Summary collapse

Methods included from I18nHelpers

#alchemy_crm_t, #i18n_t, included, #translate_model_attribute

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 34

def create
  @delivery = Delivery.new(params[:delivery])
  @mailing = @delivery.mailing = Mailing.find(params[:delivery][:mailing_id])
  if @delivery.save
    @delivery.send_chunks(
      :language_id => session[:language_id],
      :protocol => request.protocol,
      :host => request.host,
      :port => request.port,
      :locale => ::I18n.locale
    )
    flash[:notice] = alchemy_crm_t(:successfully_scheduled_mailing)
  end
  redirect_to admin_mailings_path
end

#destroyObject



66
67
68
69
70
71
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 66

def destroy
  @delivery = Delivery.find(params[:id])
  @delivery.destroy
  flash[:notice] = alchemy_crm_t(:successfully_canceled_delivery)
  render :js => "window.location.replace('#{admin_mailings_path}')"
end

#editObject



50
51
52
53
54
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 50

def edit
  @delivery = Delivery.find(params[:id])
  @mailing = @delivery.mailing
  render :layout => false
end

#indexObject



8
9
10
11
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 8

def index
  @deliveries = @mailing.deliveries.order('deliver_at DESC')
  render :layout => false
end

#newObject



13
14
15
16
17
18
19
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 13

def new
  @delivery = Delivery.new(
    :deliver_at => Time.now + 1.hour,
    :mailing => @mailing
  )
  render :layout => false
end

#showObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 21

def show
  begin
    @delivery = Delivery.find(params[:id])
    @recipients = @delivery.recipients
    @read = @delivery.recipients.select{|r| r.read}
    @reacted = @delivery.recipients.select{|r| r.reacted}
    @bounced = @delivery.recipients.select{|r| r.bounced}
  rescue
    log_error($!)
  end
  render :layout => false
end

#updateObject



56
57
58
59
60
61
62
63
64
# File 'app/controllers/alchemy_crm/admin/deliveries_controller.rb', line 56

def update
  @delivery = Delivery.find(params[:id])
  @delivery.update_attributes(params[:delivery])
  render_errors_or_redirect(
    @delivery,
    admin_mailings_path,
    alchemy_crm_t(:successfully_rescheduled_mailing)
  )
end