Compare commits

..

No commits in common. "dde8ff5ea1f699048f41a43bbea3ea0266f8f290" and "8aa6b5ac144a49849b9c86c9ab64b445cc3391cf" have entirely different histories.

15 changed files with 67 additions and 68 deletions

View File

@ -33,7 +33,7 @@ class VideolistingsController < ApplicationController
# Only allow a trusted parameter "white list" through. # Only allow a trusted parameter "white list" through.
def videolisting_params def videolisting_params
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls, :on_s3) params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls)
end end
def not_found def not_found

View File

@ -3,38 +3,21 @@ require 'tempfile'
class AmazonCopy class AmazonCopy
def download_video videolisting def download_video videolisting
if not videolisting.on_s3 file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
download_file_and_upload_to_s3 videolisting.get_video_url,
videolisting.videocode,
"mp4",
"bvideos"
download_file_and_upload_to_s3 videolisting.get_preview_url,
videolisting.videocode,
"mp4",
"bvideos_preview"
videolisting.on_s3 = true
videolisting.save
end
end
handle_asynchronously :download_video
def download_file_and_upload_to_s3 url, videocode, extension, prefix
file = Tempfile.new ["video_", ".#{extension}"], "#{Rails.root}/tmp"
begin begin
file.write HTTParty.get(url).parsed_response.force_encoding("utf-8") file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
file.flush file.flush
puts "File #{videolisting.videocode} downloaded."
s3 = AWS::S3.new s3 = AWS::S3.new
obj = s3.buckets[ENV['VIDEO_BUCKET']].objects["#{prefix}/#{videocode}.mp4"] obj = s3.buckets['digitalmarketingvideos'].objects["#{videolisting.videocode}.mp4"]
obj.write(file) obj.write(file)
puts "File #{videolisting.videocode} uploaded."
ensure ensure
file.close file.close
file.unlink file.unlink
end end
end end
handle_asynchronously :download_video
end end

View File

@ -9,20 +9,12 @@ class Videolisting < ActiveRecord::Base
after_initialize :set_defaults after_initialize :set_defaults
def get_video_url def get_video_url
if self.on_s3 == true
"http://s3.amazonaws.com/#{ENV['VIDEO_BUCKET']}/bvideos/#{videocode}.mp4"
else
"http://video2.bettervideo.com/video/pro/MP4640x360/720.#{videocode}.mp4" "http://video2.bettervideo.com/video/pro/MP4640x360/720.#{videocode}.mp4"
end end
end
def get_preview_url def get_preview_url
if self.on_s3 == true
"http://s3.amazonaws.com/#{ENV['VIDEO_BUCKET']}/bvideos_preview/#{videocode}.jpg"
else
"http://video2.bettervideo.com/video/pro/jpg640x360/720.#{videocode}.jpg" "http://video2.bettervideo.com/video/pro/jpg640x360/720.#{videocode}.jpg"
end end
end
def asseturls_array def asseturls_array
self.asseturls.split(',').collect { |url| { asseturl: url.strip } } self.asseturls.split(',').collect { |url| { asseturl: url.strip } }

View File

@ -17,11 +17,11 @@
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<%= frm.input :advertisername, <%= frm.input :advertisername,
label: 'Business Name', label: 'Advertiser Name',
hint: "The name of the company." %> hint: "The name of the company." %>
<%= frm.input :listingcode, <%= frm.input :listingcode,
label: 'Listing Code', label: 'Listing Code',
as: :hidden %> hint: "Please provide the unique opportunity id." %>
<%= frm.input :description, <%= frm.input :description,
label: 'Description', label: 'Description',
as: 'text', as: 'text',
@ -33,15 +33,24 @@
label: 'Website URL', label: 'Website URL',
hint: "Used for script research and may be used in the video if they are including websites in the video graphics." %> 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: 'MIS 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." %>
<%= frm.input :vpa_email, <%= frm.input :vpa_email,
label: 'MIS Rep 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." %>
<%= frm.input :emailaddress, <%= frm.input :emailaddress,
label: 'Email Address' %> label: 'Email Address' %>
<%= frm.input :businessphone, <%= frm.input :businessphone,
label: 'Business Phone' %> label: 'Business Phone' %>
<%= frm.input :contactphone,
label: 'Contact Phone' %>
<%= frm.input :customerfirstname,
label: 'Customer First Name' %>
<%= frm.input :customerlastname,
label: 'Customer Last Name' %>
<%= frm.input :address, <%= frm.input :address,
label: 'Address' %> label: 'Address' %>
<%= frm.input :city, <%= frm.input :city,
@ -51,6 +60,7 @@
collection: us_states%> collection: us_states%>
<%= frm.input :zip, <%= frm.input :zip,
label: 'ZIP' %> label: 'ZIP' %>
<%= frm.input :awards, <%= frm.input :awards,
label: 'Awards', label: 'Awards',
hint: "Used in script and video research." %> hint: "Used in script and video research." %>

View File

@ -1,7 +1,7 @@
<div class="nested-fields videolisting_field"> <div class="nested-fields videolisting_field">
<%= f.input :videocode, <%= f.input :videocode,
label: 'Video Code', label: 'Video Code',
hint: "Please provide the opportunity id." %> hint: "Please provide the video code id." %>
<%= f.input :voiceoverselection, <%= f.input :voiceoverselection,
label: 'Voiceover Selection', label: 'Voiceover Selection',
collection: voiceoverselection_list, collection: voiceoverselection_list,

View File

@ -4,7 +4,7 @@
<thead> <thead>
<tr> <tr>
<th>Listing Code (Form Hash)</th> <th>Listing Code (Form Hash)</th>
<th>Business</th> <th>Advertiser</th>
<th>Sent?</th> <th>Sent?</th>
<th>Percent of Videos Completed</th> <th>Percent of Videos Completed</th>
<th>Address</th> <th>Address</th>

View File

@ -34,16 +34,22 @@
<% end %> <% end %>
<% unless @campaign.vpa.blank? %> <% unless @campaign.vpa.blank? %>
<li> <li>
<p><strong>MIS Rep</strong><br> <p><strong>Client Services Rep</strong><br>
<%= @campaign.vpa %></p> <%= @campaign.vpa %></p>
</li> </li>
<% end %> <% end %>
<% unless @campaign.vpa_email.blank? %> <% unless @campaign.vpa_email.blank? %>
<li> <li>
<p><strong>MIS Rep Email</strong><br> <p><strong>Client Services Rep Email</strong><br>
<%= @campaign.vpa_email %></p> <%= @campaign.vpa_email %></p>
</li> </li>
<% end %> <% end %>
<% unless @campaign.billingcode.blank? %>
<li>
<p><strong>Billing Code</strong><br>
<%= @campaign.billingcode %></p>
</li>
<% end %>
<% unless @campaign.emailaddress.blank? %> <% unless @campaign.emailaddress.blank? %>
<li> <li>
<p><strong>Email Address</strong><br> <p><strong>Email Address</strong><br>
@ -56,6 +62,24 @@
<%= number_to_phone @campaign.businessphone %></p> <%= number_to_phone @campaign.businessphone %></p>
</li> </li>
<% end %> <% end %>
<% unless @campaign.contactphone.blank? %>
<li>
<p><strong>Contact Phone</strong><br>
<%= number_to_phone @campaign.contactphone %></p>
</li>
<% end %>
<% unless @campaign.customerfirstname.blank? %>
<li>
<p><strong>Customer First Name</strong><br>
<%= @campaign.customerfirstname %></p>
</li>
<% end %>
<% unless @campaign.customerlastname.blank? %>
<li>
<p><strong>Customer Last Name</strong><br>
<%= @campaign.customerlastname %></p>
</li>
<% end %>
<% unless @campaign.address.blank? %> <% unless @campaign.address.blank? %>
<li> <li>
<p><strong>Address</strong><br> <p><strong>Address</strong><br>

View File

@ -25,7 +25,7 @@
<div class="video-js-responsive-container"> <div class="video-js-responsive-container">
<video class="video-js vjs-blue-skin" id="bvVideo1" preload="auto" controls> <video class="video-js vjs-blue-skin" id="bvVideo1" preload="auto" controls>
<source src="<%= @videolisting.get_video_url %>" type="video/mp4"></source> <!-- Video URL goes here" --> <source src="//video2.bettervideo.com/video/PRO/MP4640x360/720.<%= @videolisting.videocode %>.mp4" type="video/mp4"></source> <!-- Video URL goes here" -->
</video> </video>
</div> </div>

View File

@ -14,7 +14,5 @@ Vidpush::Application.routes.draw do
end end
end end
authenticated :user do
match "/djweb" => DelayedJobWeb, :anchor => false, via: [:get, :post] match "/djweb" => DelayedJobWeb, :anchor => false, via: [:get, :post]
end end
end

View File

@ -1,5 +0,0 @@
class AddOnS3ToVideolisting < ActiveRecord::Migration
def change
add_column :videolistings, :on_s3, :boolean, default: nil
end
end

View File

@ -1,9 +0,0 @@
class RemoveContactphoneCustomerfirstnameCustomerlastnameBillingcodeFromCampaign < ActiveRecord::Migration
def change
remove_column :campaigns, :customerfirstname
remove_column :campaigns, :customerlastname
remove_column :campaigns, :contactphone
remove_column :campaigns, :billingcode
end
end

View File

@ -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: 20140707163626) 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"
@ -37,13 +37,17 @@ ActiveRecord::Schema.define(version: 20140707163626) do
create_table "campaigns", force: true do |t| create_table "campaigns", force: true do |t|
t.integer "clientid" t.integer "clientid"
t.string "listingcode" t.string "listingcode"
t.string "billingcode"
t.string "advertisername" t.string "advertisername"
t.string "address" t.string "address"
t.string "city" t.string "city"
t.string "state" t.string "state"
t.string "zip" t.string "zip"
t.string "emailaddress" t.string "emailaddress"
t.string "customerfirstname"
t.string "customerlastname"
t.string "businessphone" t.string "businessphone"
t.string "contactphone"
t.string "websiteurl" t.string "websiteurl"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
@ -109,7 +113,6 @@ ActiveRecord::Schema.define(version: 20140707163626) do
t.integer "campaign_id" t.integer "campaign_id"
t.string "toneofvideo" t.string "toneofvideo"
t.boolean "published" t.boolean "published"
t.boolean "on_s3"
end end
end end

View File

@ -2,6 +2,7 @@ FactoryGirl.define do
factory :campaign do factory :campaign do
# clientid 720 # clientid 720
sequence(:billingcode) { |x| "billingcode#{x}" }
sequence(:listingcode) { |x| "listingcode#{x}" } sequence(:listingcode) { |x| "listingcode#{x}" }
address "123 Anywhere Street" address "123 Anywhere Street"
advertisername "Bob's BBQ" advertisername "Bob's BBQ"
@ -11,6 +12,9 @@ FactoryGirl.define do
categories "Food, BBQ, Southern California, Restaurant, Cooking" categories "Food, BBQ, Southern California, Restaurant, Cooking"
city "Some City" city "Some City"
companycolors "Brown, Red" companycolors "Brown, Red"
contactphone "5555551212"
customerfirstname "Bob"
customerlastname "De Bbq"
description "Bob's BBQ is the best BBQ in the Some City area of Southern Cali" description "Bob's BBQ is the best BBQ in the Some City area of Southern Cali"
emailaddress "bob@bobsbbq.com" emailaddress "bob@bobsbbq.com"
facebookurl "facebook.com/bobsbbq" facebookurl "facebook.com/bobsbbq"

View File

@ -9,7 +9,6 @@ FactoryGirl.define do
producttypeid 721 producttypeid 721
toneofvideo "Upbeat, targeting families but also show business functions." toneofvideo "Upbeat, targeting families but also show business functions."
voiceoverselection 3 voiceoverselection 3
on_s3 false
published {|x| false } published {|x| false }
sequence(:videocode) {|x| "video#{x}" } sequence(:videocode) {|x| "video#{x}" }
end end

View File

@ -21,11 +21,11 @@ describe Videolisting, 'associations' do
it "can get a video url" do it "can get a video url" do
video = FactoryGirl.build(:videolisting) video = FactoryGirl.build(:videolisting)
expect(video.get_video_url).to include("#{video.videocode}.mp4") expect(video.get_video_url).to include("http://video2.bettervideo.com/video/pro/MP4640x360/720")
end end
it "can get a preview url" do it "can get a preview url" do
video = FactoryGirl.build(:videolisting) video = FactoryGirl.build(:videolisting)
expect(video.get_preview_url).to include("#{video.videocode}.jpg") expect(video.get_preview_url).to include("http://video2.bettervideo.com/video/pro/jpg640x360/720.")
end end
end end