Compare commits
10 Commits
8aa6b5ac14
...
dde8ff5ea1
Author | SHA1 | Date | |
---|---|---|---|
|
dde8ff5ea1 | ||
|
ccae65f27d | ||
|
e5e2d07ce9 | ||
|
8fdaba4c0e | ||
|
58c95ccca4 | ||
|
834648bd57 | ||
|
ab3b689045 | ||
|
77adf17622 | ||
|
eda5c25af2 | ||
|
784b083c05 |
|
@ -33,7 +33,7 @@ class VideolistingsController < ApplicationController
|
|||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def videolisting_params
|
||||
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls)
|
||||
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls, :on_s3)
|
||||
end
|
||||
|
||||
def not_found
|
||||
|
|
|
@ -3,21 +3,38 @@ require 'tempfile'
|
|||
|
||||
class AmazonCopy
|
||||
def download_video videolisting
|
||||
file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
|
||||
if not videolisting.on_s3
|
||||
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
|
||||
file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
|
||||
file.write HTTParty.get(url).parsed_response.force_encoding("utf-8")
|
||||
file.flush
|
||||
puts "File #{videolisting.videocode} downloaded."
|
||||
|
||||
s3 = AWS::S3.new
|
||||
obj = s3.buckets['digitalmarketingvideos'].objects["#{videolisting.videocode}.mp4"]
|
||||
obj = s3.buckets[ENV['VIDEO_BUCKET']].objects["#{prefix}/#{videocode}.mp4"]
|
||||
obj.write(file)
|
||||
puts "File #{videolisting.videocode} uploaded."
|
||||
|
||||
ensure
|
||||
file.close
|
||||
file.unlink
|
||||
end
|
||||
end
|
||||
handle_asynchronously :download_video
|
||||
|
||||
end
|
|
@ -9,11 +9,19 @@ class Videolisting < ActiveRecord::Base
|
|||
after_initialize :set_defaults
|
||||
|
||||
def get_video_url
|
||||
"http://video2.bettervideo.com/video/pro/MP4640x360/720.#{videocode}.mp4"
|
||||
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"
|
||||
end
|
||||
end
|
||||
|
||||
def get_preview_url
|
||||
"http://video2.bettervideo.com/video/pro/jpg640x360/720.#{videocode}.jpg"
|
||||
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"
|
||||
end
|
||||
end
|
||||
|
||||
def asseturls_array
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<%= frm.input :advertisername,
|
||||
label: 'Advertiser Name',
|
||||
label: 'Business Name',
|
||||
hint: "The name of the company." %>
|
||||
<%= frm.input :listingcode,
|
||||
label: 'Listing Code',
|
||||
hint: "Please provide the unique opportunity id." %>
|
||||
as: :hidden %>
|
||||
<%= frm.input :description,
|
||||
label: 'Description',
|
||||
as: 'text',
|
||||
|
@ -33,24 +33,15 @@
|
|||
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,
|
||||
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." %>
|
||||
label: 'MIS Rep' %>
|
||||
<%= 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." %>
|
||||
<%= frm.input :emailaddress,
|
||||
label: 'MIS Rep Email' %>
|
||||
|
||||
<%= frm.input :emailaddress,
|
||||
label: 'Email Address' %>
|
||||
<%= frm.input :businessphone,
|
||||
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,
|
||||
label: 'Address' %>
|
||||
<%= frm.input :city,
|
||||
|
@ -60,7 +51,6 @@
|
|||
collection: us_states%>
|
||||
<%= frm.input :zip,
|
||||
label: 'ZIP' %>
|
||||
|
||||
<%= frm.input :awards,
|
||||
label: 'Awards',
|
||||
hint: "Used in script and video research." %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="nested-fields videolisting_field">
|
||||
<%= f.input :videocode,
|
||||
label: 'Video Code',
|
||||
hint: "Please provide the video code id." %>
|
||||
hint: "Please provide the opportunity id." %>
|
||||
<%= f.input :voiceoverselection,
|
||||
label: 'Voiceover Selection',
|
||||
collection: voiceoverselection_list,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Listing Code (Form Hash)</th>
|
||||
<th>Advertiser</th>
|
||||
<th>Business</th>
|
||||
<th>Sent?</th>
|
||||
<th>Percent of Videos Completed</th>
|
||||
<th>Address</th>
|
||||
|
|
|
@ -34,22 +34,16 @@
|
|||
<% end %>
|
||||
<% unless @campaign.vpa.blank? %>
|
||||
<li>
|
||||
<p><strong>Client Services Rep</strong><br>
|
||||
<p><strong>MIS Rep</strong><br>
|
||||
<%= @campaign.vpa %></p>
|
||||
</li>
|
||||
<% end %>
|
||||
<% unless @campaign.vpa_email.blank? %>
|
||||
<li>
|
||||
<p><strong>Client Services Rep Email</strong><br>
|
||||
<p><strong>MIS Rep Email</strong><br>
|
||||
<%= @campaign.vpa_email %></p>
|
||||
</li>
|
||||
<% end %>
|
||||
<% unless @campaign.billingcode.blank? %>
|
||||
<li>
|
||||
<p><strong>Billing Code</strong><br>
|
||||
<%= @campaign.billingcode %></p>
|
||||
</li>
|
||||
<% end %>
|
||||
<% unless @campaign.emailaddress.blank? %>
|
||||
<li>
|
||||
<p><strong>Email Address</strong><br>
|
||||
|
@ -62,24 +56,6 @@
|
|||
<%= number_to_phone @campaign.businessphone %></p>
|
||||
</li>
|
||||
<% 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? %>
|
||||
<li>
|
||||
<p><strong>Address</strong><br>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<div class="video-js-responsive-container">
|
||||
<video class="video-js vjs-blue-skin" id="bvVideo1" preload="auto" controls>
|
||||
<source src="//video2.bettervideo.com/video/PRO/MP4640x360/720.<%= @videolisting.videocode %>.mp4" type="video/mp4"></source> <!-- Video URL goes here" -->
|
||||
<source src="<%= @videolisting.get_video_url %>" type="video/mp4"></source> <!-- Video URL goes here" -->
|
||||
</video>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -14,5 +14,7 @@ Vidpush::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
match "/djweb" => DelayedJobWeb, :anchor => false, via: [:get, :post]
|
||||
authenticated :user do
|
||||
match "/djweb" => DelayedJobWeb, :anchor => false, via: [:get, :post]
|
||||
end
|
||||
end
|
||||
|
|
5
db/migrate/20140529180650_add_on_s3_to_videolisting.rb
Normal file
5
db/migrate/20140529180650_add_on_s3_to_videolisting.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddOnS3ToVideolisting < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :videolistings, :on_s3, :boolean, default: nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class RemoveContactphoneCustomerfirstnameCustomerlastnameBillingcodeFromCampaign < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :campaigns, :customerfirstname
|
||||
remove_column :campaigns, :customerlastname
|
||||
remove_column :campaigns, :contactphone
|
||||
remove_column :campaigns, :billingcode
|
||||
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140505153412) do
|
||||
ActiveRecord::Schema.define(version: 20140707163626) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -37,17 +37,13 @@ ActiveRecord::Schema.define(version: 20140505153412) do
|
|||
create_table "campaigns", force: true do |t|
|
||||
t.integer "clientid"
|
||||
t.string "listingcode"
|
||||
t.string "billingcode"
|
||||
t.string "advertisername"
|
||||
t.string "address"
|
||||
t.string "city"
|
||||
t.string "state"
|
||||
t.string "zip"
|
||||
t.string "emailaddress"
|
||||
t.string "customerfirstname"
|
||||
t.string "customerlastname"
|
||||
t.string "businessphone"
|
||||
t.string "contactphone"
|
||||
t.string "websiteurl"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
@ -113,6 +109,7 @@ ActiveRecord::Schema.define(version: 20140505153412) do
|
|||
t.integer "campaign_id"
|
||||
t.string "toneofvideo"
|
||||
t.boolean "published"
|
||||
t.boolean "on_s3"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ FactoryGirl.define do
|
|||
|
||||
factory :campaign do
|
||||
# clientid 720
|
||||
sequence(:billingcode) { |x| "billingcode#{x}" }
|
||||
sequence(:listingcode) { |x| "listingcode#{x}" }
|
||||
address "123 Anywhere Street"
|
||||
advertisername "Bob's BBQ"
|
||||
|
@ -12,9 +11,6 @@ FactoryGirl.define do
|
|||
categories "Food, BBQ, Southern California, Restaurant, Cooking"
|
||||
city "Some City"
|
||||
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"
|
||||
emailaddress "bob@bobsbbq.com"
|
||||
facebookurl "facebook.com/bobsbbq"
|
||||
|
|
|
@ -9,6 +9,7 @@ FactoryGirl.define do
|
|||
producttypeid 721
|
||||
toneofvideo "Upbeat, targeting families but also show business functions."
|
||||
voiceoverselection 3
|
||||
on_s3 false
|
||||
published {|x| false }
|
||||
sequence(:videocode) {|x| "video#{x}" }
|
||||
end
|
||||
|
|
|
@ -21,11 +21,11 @@ describe Videolisting, 'associations' do
|
|||
|
||||
it "can get a video url" do
|
||||
video = FactoryGirl.build(:videolisting)
|
||||
expect(video.get_video_url).to include("http://video2.bettervideo.com/video/pro/MP4640x360/720")
|
||||
expect(video.get_video_url).to include("#{video.videocode}.mp4")
|
||||
end
|
||||
|
||||
it "can get a preview url" do
|
||||
video = FactoryGirl.build(:videolisting)
|
||||
expect(video.get_preview_url).to include("http://video2.bettervideo.com/video/pro/jpg640x360/720.")
|
||||
expect(video.get_preview_url).to include("#{video.videocode}.jpg")
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user