Class: Forge::DispatchesController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/dispatches_controller.rb

Instance Method Summary collapse

Methods inherited from ForgeController

#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor

Methods inherited from ApplicationController

#app_init

Instance Method Details

#chart_dataObject



26
27
28
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 26

def chart_data
  render :json => @dispatch.chart_data
end

#clicksObject



34
35
36
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 34

def clicks
  @clicks = DispatchLinkClick.includes(:dispatch_link).where("dispatch_links.dispatch_id = ?", @dispatch.id).paginate(:per_page => 15, :page => params[:page])
end

#createObject



42
43
44
45
46
47
48
49
50
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 42

def create
  @dispatch = Dispatch.new(params[:dispatch])
  if @dispatch.save
    flash[:notice] = 'Dispatch was successfully created.'
    redirect_to(forge_dispatches_path)
  else
    render :action => "new"
  end
end

#destroyObject



61
62
63
64
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 61

def destroy
  @dispatch.destroy
  redirect_to(forge_dispatches_path)
end

#editObject



19
20
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 19

def edit
end

#indexObject



5
6
7
8
9
10
11
12
13
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 5

def index
  respond_to do |format|
    format.html { @dispatches = Dispatch.paginate(:per_page => 10, :page => params[:page]) }
    format.js { 
      @dispatches = Dispatch.where("title LIKE ?", "%#{params[:q]}%")
      render :partial => "dispatch", :collection => @dispatches
    }
  end
end

#newObject



15
16
17
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 15

def new
  @dispatch = Dispatch.new
end

#opensObject



30
31
32
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 30

def opens
  @opens = @dispatch.opens.paginate(:per_page => 15, :page => params[:page])
end

#queueObject



66
67
68
69
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 66

def queue
  @groups = SubscriberGroup.all
  @total_subscribers = Subscriber.count
end

#send_allObject



77
78
79
80
81
82
83
84
85
86
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 77

def send_all
  if params[:group_send] && params[:group_ids].blank?
    flash[:warning] = "You must select the groups to send the dispatch to."
    redirect_to queue_forge_dispatch_path(@dispatch)
  else
    @dispatch.deliver!(params[:group_ids])
    flash[:notice] = "Your dispatch is currently sending."
    redirect_to forge_dispatches_path
  end
end

#showObject



22
23
24
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 22

def show
  @dispatch = Dispatch.find(params[:id], :include => [:messages, :queued_messages, :opens, :sent_messages, :failed_messages])
end

#test_sendObject



71
72
73
74
75
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 71

def test_send
  DispatchMailer.dispatch(@dispatch, params[:test_send_email], "Admin", current_user.id).deliver
  flash[:notice] = "A copy of the dispatch was sent to #{params[:test_send_email]}."
  redirect_to queue_forge_dispatch_path(@dispatch)
end

#unsubscribesObject



38
39
40
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 38

def unsubscribes
  @unsubscribes = @dispatch.unsubscribes.paginate(:per_page => 15, :page => params[:page])
end

#updateObject



52
53
54
55
56
57
58
59
# File 'lib/forge/app/controllers/forge/dispatches_controller.rb', line 52

def update
  if @dispatch.update_attributes(params[:dispatch])
    flash[:notice] = 'Dispatch was successfully updated.'
    redirect_to(forge_dispatches_path)
  else
    render :action => "edit"
  end
end