Class: Manage::MessagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Manage::MessagesController
- Defined in:
- app/controllers/manage/messages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #datatable ⇒ Object
- #deliver ⇒ Object
- #destroy ⇒ Object
- #duplicate ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #live_preview ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/manage/messages_controller.rb', line 26 def create = Message.new() .save respond_with(:manage, ) end |
#datatable ⇒ Object
10 11 12 |
# File 'app/controllers/manage/messages_controller.rb', line 10 def datatable render json: BulkMessageDatatable.new(view_context) end |
#deliver ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/manage/messages_controller.rb', line 42 def deliver if .automated? flash[:notice] = "Automated messages cannot be manually delivered. Only bulk messages can." return redirect_to () end if .status != "drafted" flash[:notice] = "Message cannot be re-delivered" return redirect_to end .update_attribute(:queued_at, Time.now) BulkMessageWorker.perform_async(.id) flash[:notice] = "Message queued for delivery" redirect_to () end |
#destroy ⇒ Object
37 38 39 40 |
# File 'app/controllers/manage/messages_controller.rb', line 37 def destroy .destroy respond_with(:manage, ) end |
#duplicate ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/manage/messages_controller.rb', line 69 def duplicate = .dup .update_attributes( delivered_at: nil, started_at: nil, queued_at: nil, name: "Copy of #{@message.name}" ) .save redirect_to (.reload) end |
#edit ⇒ Object
23 24 |
# File 'app/controllers/manage/messages_controller.rb', line 23 def edit end |
#index ⇒ Object
7 8 |
# File 'app/controllers/manage/messages_controller.rb', line 7 def index end |
#live_preview ⇒ Object
62 63 64 65 66 67 |
# File 'app/controllers/manage/messages_controller.rb', line 62 def live_preview body = params[:body] || '' = Message.new(body: body) email = Mailer.(nil, current_user.id, ) render html: email.body.raw_source.html_safe end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/manage/messages_controller.rb', line 18 def new = Message.new respond_with(:manage, ) end |
#preview ⇒ Object
57 58 59 60 |
# File 'app/controllers/manage/messages_controller.rb', line 57 def preview email = Mailer.(.id, current_user.id) render html: email.body.raw_source.html_safe end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/manage/messages_controller.rb', line 14 def show respond_with(:manage, ) end |
#update ⇒ Object
32 33 34 35 |
# File 'app/controllers/manage/messages_controller.rb', line 32 def update .update_attributes() respond_with(:manage, ) end |