Compare commits

..

10 Commits

Author SHA1 Message Date
Tyrel Souza
dde8ff5ea1 remove extraneous factory stuff 2014-07-07 12:58:31 -04:00
Tyrel Souza
ccae65f27d added migration 2014-07-07 12:39:27 -04:00
Tyrel Souza
e5e2d07ce9 hiding some fields 2014-07-02 14:30:08 -04:00
Tyrel Souza
8fdaba4c0e added necessity to be logged in to view djweb 2014-05-30 12:01:50 -04:00
Tyrel Souza
58c95ccca4 fix tests to add new field. 2014-05-29 16:57:34 -04:00
Tyrel Souza
834648bd57 Merge pull request #1 from propelmarketing/download_files
Download files and upload to S3
2014-05-29 16:47:26 -04:00
Tyrel Souza
ab3b689045 move line to proper place 2014-05-29 16:44:23 -04:00
Tyrel Souza
77adf17622 refactor 2014-05-29 14:53:10 -04:00
Tyrel Souza
eda5c25af2 added preview video on s3 2014-05-29 14:34:52 -04:00
Tyrel Souza
784b083c05 adding prefix to video 2014-05-29 14:04:39 -04:00
15 changed files with 68 additions and 67 deletions

View File

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

View File

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

View File

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

View File

@ -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." %>

View File

@ -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,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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"

View File

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

View File

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