Class: Admin::MessagesController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/admin/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#deliverObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/admin/messages_controller.rb', line 20

def deliver
  case params['delivery']
  when "all"
    @readers = @message.possible_readers
  when "inactive"
    @readers = @message.inactive_readers
  when "unsent"
    @readers = @message.undelivered_readers
  when "selected"
    @readers = @message.possible_readers.find(params['recipients'])
  else
    redirect_to admin_message_url(@message)
    return
  end
  failures = @message.deliver(@readers) || []
  if failures.any?
    if failures.length == @readers.length
      flash[:error] = t("reader_extension.all_deliveries_failed")
    else
      addresses = failures.map(&:email).to_sentence
      flash[:notice] = t("reader_extension.some_deliveries_failed")
    end
  else
    flash[:notice] = t("reader_extension.message_delivered")
  end
  redirect_to admin_message_url(@message)
end

#previewObject

mock email view called into an iframe in the :show view the view calls @message.preview, which returns the message body



16
17
18
# File 'app/controllers/admin/messages_controller.rb', line 16

def preview
  render :layout => false
end

#showObject

here :show is the preview/send page continue_url is extended below to redirect to show rather than index after editing.



10
11
12
# File 'app/controllers/admin/messages_controller.rb', line 10

def show
  
end