Added an emailer

This commit is contained in:
Tyrel Souza 2014-05-05 14:07:33 -04:00
parent 93cdc5ef54
commit 14f6845dc0
16 changed files with 56 additions and 9 deletions

View File

@ -80,7 +80,7 @@ class CampaignsController < ApplicationController
:businessphone, :categories, :city, :companycolors, :contactphone,
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
:vpa, :websiteurl, :zip,
:vpa, :vpa_email, :websiteurl, :zip,
videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus,
:keywords, :musicselection, :notes,

View File

@ -5,6 +5,7 @@ class VideolistingsController < ApplicationController
if @videolisting.published?
@message = "Campaign Already Published."
elsif @videolisting.campaign.sent?
VideolistingMailer.videolisting_complete(@videolisting).deliver
@videolisting.published = true
@videolisting.save

View 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

View File

@ -19,12 +19,12 @@ class BetterVideo
resp = JSON.parse(response.body)
puts resp
if resp["errorcode"] == 0
if resp["errorcode"].to_i == 0
resp[:success] = true
resp[:message] = "Successfully submitted to BetterVideo, Please wait."
else
resp[:message] = "Error Code #{resp["errorcode"]}: #{resp["errormessage"]}"
if resp["errorcode"] == 1
if resp["errorcode"].to_i == 1
resp[:message] += "Please Contact Dev"
end
end

View File

@ -25,9 +25,8 @@ class Campaign < ActiveRecord::Base
0
end
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 }
campaigns = {campaigns: [campaign,], key: "PRO1234"}
campaigns.to_json

View File

@ -53,7 +53,6 @@ class Videolisting < ActiveRecord::Base
def send_notification_after_change
if self.published_changed? && self.published?
#TODO: SEND OUT EMAIL HERE TO CLIENT SERVICES REP
end
true
end

View File

@ -24,5 +24,6 @@ json.videolistings campaign.videolistings.each do |videolisting|
json.partial! 'campaigns/videolisting', videolisting: videolisting
end
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.zip campaign.zip if campaign.zip

View File

@ -32,9 +32,12 @@
<%= frm.input :websiteurl,
label: 'Website URL',
hint: "Used for script research and may be used in the video if they are including websites in the video graphics." %>
<%= frm.input :vpa,
<%= frm.input :vpa,
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." %>
<%= 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,
label: 'Billing Code',
hint: "Market or billing code. Should match a billing code in the BetterVideo system so it can be associated." %>

View File

@ -40,6 +40,12 @@
<%= @campaign.vpa %></p>
</li>
<% 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? %>
<li>
<p><strong>Billing Code</strong><br>

View 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>

View File

@ -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) %>

View File

@ -3,3 +3,5 @@ require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Vidpush::Application.initialize!

View File

@ -15,6 +15,7 @@ Vidpush::Application.configure do
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :development
# 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_mailer.default_url_options = { host: 'localhost:3000' }
end

View File

@ -0,0 +1,5 @@
class AddVpaEmailToCampaign < ActiveRecord::Migration
def change
add_column :campaigns, :vpa_email, :string
end
end

View File

@ -11,7 +11,7 @@
#
# 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
enable_extension "plpgsql"
@ -62,6 +62,7 @@ ActiveRecord::Schema.define(version: 20140502151827) do
t.string "targetaudience"
t.string "tollfreephone"
t.string "vpa"
t.string "vpa_email"
end
create_table "delayed_jobs", force: true do |t|

View File

@ -0,0 +1,5 @@
require "spec_helper"
describe VideolistingMailer do
pending "add some examples to (or delete) #{__FILE__}"
end