Added an emailer
This commit is contained in:
parent
93cdc5ef54
commit
14f6845dc0
@ -80,7 +80,7 @@ class CampaignsController < ApplicationController
|
|||||||
:businessphone, :categories, :city, :companycolors, :contactphone,
|
:businessphone, :categories, :city, :companycolors, :contactphone,
|
||||||
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
|
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
|
||||||
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
|
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
|
||||||
:vpa, :websiteurl, :zip,
|
:vpa, :vpa_email, :websiteurl, :zip,
|
||||||
|
|
||||||
videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus,
|
videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus,
|
||||||
:keywords, :musicselection, :notes,
|
:keywords, :musicselection, :notes,
|
||||||
|
@ -5,6 +5,7 @@ class VideolistingsController < ApplicationController
|
|||||||
if @videolisting.published?
|
if @videolisting.published?
|
||||||
@message = "Campaign Already Published."
|
@message = "Campaign Already Published."
|
||||||
elsif @videolisting.campaign.sent?
|
elsif @videolisting.campaign.sent?
|
||||||
|
VideolistingMailer.videolisting_complete(@videolisting).deliver
|
||||||
@videolisting.published = true
|
@videolisting.published = true
|
||||||
@videolisting.save
|
@videolisting.save
|
||||||
|
|
||||||
|
9
app/mailers/videolisting_mailer.rb
Normal file
9
app/mailers/videolisting_mailer.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class VideolistingMailer < ActionMailer::Base
|
||||||
|
default from: "noreply@propelmarketing.com"
|
||||||
|
|
||||||
|
def videolisting_complete(videolisting)
|
||||||
|
@to = videolisting.campaign.vpa_email
|
||||||
|
@listing = videolisting
|
||||||
|
mail(to: @to, subject: "A Video Listing has been completed by Better Video")
|
||||||
|
end
|
||||||
|
end
|
@ -19,12 +19,12 @@ class BetterVideo
|
|||||||
resp = JSON.parse(response.body)
|
resp = JSON.parse(response.body)
|
||||||
puts resp
|
puts resp
|
||||||
|
|
||||||
if resp["errorcode"] == 0
|
if resp["errorcode"].to_i == 0
|
||||||
resp[:success] = true
|
resp[:success] = true
|
||||||
resp[:message] = "Successfully submitted to BetterVideo, Please wait."
|
resp[:message] = "Successfully submitted to BetterVideo, Please wait."
|
||||||
else
|
else
|
||||||
resp[:message] = "Error Code #{resp["errorcode"]}: #{resp["errormessage"]}"
|
resp[:message] = "Error Code #{resp["errorcode"]}: #{resp["errormessage"]}"
|
||||||
if resp["errorcode"] == 1
|
if resp["errorcode"].to_i == 1
|
||||||
resp[:message] += "Please Contact Dev"
|
resp[:message] += "Please Contact Dev"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,9 +25,8 @@ class Campaign < ActiveRecord::Base
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def to_bettervideo_format
|
def to_bettervideo_format
|
||||||
campaign = self.as_json
|
campaign = self.as_json(except: [:vpa_email,])
|
||||||
campaign[:videolistings] = self.videolistings.all.map {|vl| vl.as_json }
|
campaign[:videolistings] = self.videolistings.all.map {|vl| vl.as_json }
|
||||||
campaigns = {campaigns: [campaign,], key: "PRO1234"}
|
campaigns = {campaigns: [campaign,], key: "PRO1234"}
|
||||||
campaigns.to_json
|
campaigns.to_json
|
||||||
|
@ -53,7 +53,6 @@ class Videolisting < ActiveRecord::Base
|
|||||||
|
|
||||||
def send_notification_after_change
|
def send_notification_after_change
|
||||||
if self.published_changed? && self.published?
|
if self.published_changed? && self.published?
|
||||||
#TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP
|
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -24,5 +24,6 @@ json.videolistings campaign.videolistings.each do |videolisting|
|
|||||||
json.partial! 'campaigns/videolisting', videolisting: videolisting
|
json.partial! 'campaigns/videolisting', videolisting: videolisting
|
||||||
end
|
end
|
||||||
json.vpa campaign.vpa if campaign.vpa
|
json.vpa campaign.vpa if campaign.vpa
|
||||||
|
json.vpa_email campaign.vpa_email if campaign.vpa_email
|
||||||
json.websiteurl campaign.websiteurl if campaign.websiteurl
|
json.websiteurl campaign.websiteurl if campaign.websiteurl
|
||||||
json.zip campaign.zip if campaign.zip
|
json.zip campaign.zip if campaign.zip
|
@ -35,6 +35,9 @@
|
|||||||
<%= frm.input :vpa,
|
<%= frm.input :vpa,
|
||||||
label: 'Client Service Rep',
|
label: 'Client Service Rep',
|
||||||
hint: "This is the full name of the client services representative, as entered in the BetterVideo system associated with this order. This feature is designed for sales reps that are well known to the system. This feature is typically used for automated communication." %>
|
hint: "This is the full name of the client services representative, as entered in the BetterVideo system associated with this order. This feature is designed for sales reps that are well known to the system. This feature is typically used for automated communication." %>
|
||||||
|
<%= frm.input :vpa_email,
|
||||||
|
label: 'Client Service Rep Email',
|
||||||
|
hint: "The Email for the above Client Service Rep, (not sent to BetterVideo, just used for video completion emails)" %>
|
||||||
<%= frm.input :billingcode,
|
<%= frm.input :billingcode,
|
||||||
label: 'Billing Code',
|
label: 'Billing Code',
|
||||||
hint: "Market or billing code. Should match a billing code in the BetterVideo system so it can be associated." %>
|
hint: "Market or billing code. Should match a billing code in the BetterVideo system so it can be associated." %>
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
<%= @campaign.vpa %></p>
|
<%= @campaign.vpa %></p>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% unless @campaign.vpa_email.blank? %>
|
||||||
|
<li>
|
||||||
|
<p><strong>Client Services Rep Email</strong><br>
|
||||||
|
<%= @campaign.vpa_email %></p>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
<% unless @campaign.billingcode.blank? %>
|
<% unless @campaign.billingcode.blank? %>
|
||||||
<li>
|
<li>
|
||||||
<p><strong>Billing Code</strong><br>
|
<p><strong>Billing Code</strong><br>
|
||||||
|
11
app/views/videolisting_mailer/videolisting_complete.html.erb
Normal file
11
app/views/videolisting_mailer/videolisting_complete.html.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>A Video listing is complete.</h1>
|
||||||
|
<p>The video listing with video code: <%= @listing.videocode %> has been completed by Better video.</p>
|
||||||
|
<p><%= link_to "Preview Video Before setting live.", campaign_videolisting_url(@listing.campaign.listingcode, @listing.videocode) %></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,5 @@
|
|||||||
|
A Video listing is complete.
|
||||||
|
==============================
|
||||||
|
The video listing with video code: <%= @listing.videocode %> has been completed by Better video.
|
||||||
|
|
||||||
|
<%= campaign_videolisting_url(@listing.campaign.listingcode, @listing.videocode) %>
|
@ -3,3 +3,5 @@ require File.expand_path('../application', __FILE__)
|
|||||||
|
|
||||||
# Initialize the Rails application.
|
# Initialize the Rails application.
|
||||||
Vidpush::Application.initialize!
|
Vidpush::Application.initialize!
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ Vidpush::Application.configure do
|
|||||||
|
|
||||||
# Don't care if the mailer can't send.
|
# Don't care if the mailer can't send.
|
||||||
config.action_mailer.raise_delivery_errors = true
|
config.action_mailer.raise_delivery_errors = true
|
||||||
|
config.action_mailer.delivery_method = :development
|
||||||
|
|
||||||
|
|
||||||
# Print deprecation notices to the Rails logger.
|
# Print deprecation notices to the Rails logger.
|
||||||
@ -32,7 +33,6 @@ Vidpush::Application.configure do
|
|||||||
config.action_controller.action_on_unpermitted_parameters = :raise
|
config.action_controller.action_on_unpermitted_parameters = :raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
5
db/migrate/20140505153412_add_vpa_email_to_campaign.rb
Normal file
5
db/migrate/20140505153412_add_vpa_email_to_campaign.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddVpaEmailToCampaign < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :campaigns, :vpa_email, :string
|
||||||
|
end
|
||||||
|
end
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140502151827) do
|
ActiveRecord::Schema.define(version: 20140505153412) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -62,6 +62,7 @@ ActiveRecord::Schema.define(version: 20140502151827) do
|
|||||||
t.string "targetaudience"
|
t.string "targetaudience"
|
||||||
t.string "tollfreephone"
|
t.string "tollfreephone"
|
||||||
t.string "vpa"
|
t.string "vpa"
|
||||||
|
t.string "vpa_email"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "delayed_jobs", force: true do |t|
|
create_table "delayed_jobs", force: true do |t|
|
||||||
|
5
spec/mailers/videolisting_mailer_spec.rb
Normal file
5
spec/mailers/videolisting_mailer_spec.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe VideolistingMailer do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user