diff --git a/Gemfile.lock b/Gemfile.lock index 31c581a..023fe19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,7 +82,6 @@ GEM thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.5) - docile (1.1.3) dotenv (0.10.0) dotenv-rails (0.10.0) dotenv (= 0.10.0) @@ -173,11 +172,10 @@ GEM sprockets-rails (~> 2.0.0) shoulda-matchers (2.5.0) activesupport (>= 3.0.0) - simplecov (0.8.2) - docile (~> 1.1.0) - multi_json - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) + simplecov (0.7.1) + multi_json (~> 1.0) + simplecov-html (~> 0.7.1) + simplecov-html (0.7.1) slop (3.5.0) spring (1.1.2) spring-commands-rspec (1.0.1) @@ -249,7 +247,7 @@ DEPENDENCIES sass-rails (~> 4.0.2) shoulda-matchers simple_form! - simplecov + simplecov (~> 0.7.1) spring spring-commands-rspec timecop diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index 6c14418..6072fc6 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -1,15 +1,17 @@ class CampaignsController < ApplicationController before_action :set_campaign, only: [:show, :edit, :update, :destroy] + before_action :set_api_key def index @campaigns = Campaign.all end def show - respond_to do |format| - format.json { render json: @campaign, include: [:videolistings,] } - format.html { render html: @campaign } - end + # respond_to do |format| + # format.json { render json: @campaign, include: [:videolistings,] } + # format.html { render html: @campaign } + # end + @campaign end def new @@ -56,17 +58,24 @@ class CampaignsController < ApplicationController end def campaign_params - params.require(:campaign).permit(:id, :clientid, :listingcode, :billingcode, :advertisername, :address1, - :address2, :city, :state, :zip, :emailaddress, :customerfirstname, - :customerlastname, :salesrep, :salesrepemail, :businessphone, - :contactphone, :websiteurl, - videolistings_attributes: [:id, :videocode, :producttypeid, :remoteassetsarchive, - :voiceoverselection, :musicselection, :clientprovidedscript, - :keywords, :focus, :notes, :asseturls,]) + params.require(:campaign).permit(:id, :address, :advertisername, :awards, :background, :billingcode, + :businessphone, :categories, :city, :clientid, :companycolors, :contactphone, + :customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl, + :listingcode, :productsandservices, :state, :targetaudience, :tollfreephone, + :vpa, :websiteurl, :zip, + videolistings_attributes: [:id, :asseturls, :clientprovidedscript, :focus, + :keywords, :musicselection, :notes, :producttypeid, + :videocode, :voiceoverselection, + ]) end def not_found raise ActionController::RoutingError.new("Not Found by clientid") end + + def set_api_key + @BETTER_VIDEO_API_KEY = ENV['BETTER_VIDEO_API_KEY'] + @BETTER_VIDEO_API_KEY ||= "propel test key" + end end diff --git a/app/views/campaigns/_campaign.json.jbuilder b/app/views/campaigns/_campaign.json.jbuilder new file mode 100644 index 0000000..6ca6b59 --- /dev/null +++ b/app/views/campaigns/_campaign.json.jbuilder @@ -0,0 +1,28 @@ +json.key @BETTER_VIDEO_API_KEY +json.address campaign.address if campaign.address +json.advertisername campaign.advertisername if campaign.advertisername +json.awards campaign.awards if campaign.awards +json.background campaign.background if campaign.background +json.billingcode campaign.billingcode if campaign.billingcode +json.businessphone campaign.businessphone if campaign.businessphone +json.categories campaign.categories if campaign.categories +json.city campaign.city if campaign.city +json.clientid campaign.clientid if campaign.clientid +json.companycolors campaign.companycolors if campaign.companycolors +json.contactphone campaign.contactphone if campaign.contactphone +json.customerfirstname campaign.customerfirstname if campaign.customerfirstname +json.customerlastname campaign.customerlastname if campaign.customerlastname +json.description campaign.description if campaign.description +json.emailaddress campaign.emailaddress if campaign.emailaddress +json.facebookurl campaign.facebookurl if campaign.facebookurl +json.listingcode campaign.listingcode if campaign.listingcode +json.productsandservices campaign.productsandservices if campaign.productsandservices +json.state campaign.state if campaign.state +json.targetaudience campaign.targetaudience if campaign.targetaudience +json.tollfreephone campaign.tollfreephone if campaign.tollfreephone +json.videolistings campaign.videolistings.each do |videolisting| + json.partial! 'campaigns/videolisting', videolisting: videolisting +end +json.vpa campaign.vpa if campaign.vpa +json.websiteurl campaign.websiteurl if campaign.websiteurl +json.zip campaign.zip if campaign.zip \ No newline at end of file diff --git a/app/views/campaigns/_videolisting.json.jbuilder b/app/views/campaigns/_videolisting.json.jbuilder new file mode 100644 index 0000000..139d68d --- /dev/null +++ b/app/views/campaigns/_videolisting.json.jbuilder @@ -0,0 +1,10 @@ +json.assets videolisting.asseturls_array if videolisting.asseturls_array +json.clientprovidedscript videolisting.clientprovidedscript if videolisting.clientprovidedscript +json.focus videolisting.focus if videolisting.focus +json.keywords videolisting.keywords if videolisting.keywords +json.musicselection videolisting.musicselection if videolisting.musicselection +json.notes videolisting.notes if videolisting.notes +json.producttypeid videolisting.producttypeid if videolisting.producttypeid +json.toneofvideo videolisting.toneofvideo if videolisting.toneofvideo +json.videocode videolisting.videocode if videolisting.videocode +json.voiceoverselection videolisting.voiceoverselection if videolisting.voiceoverselection \ No newline at end of file diff --git a/app/views/campaigns/index.json.jbuilder b/app/views/campaigns/index.json.jbuilder index eb94506..7349ac4 100644 --- a/app/views/campaigns/index.json.jbuilder +++ b/app/views/campaigns/index.json.jbuilder @@ -1,31 +1,3 @@ json.campaigns @campaigns do |campaign| - json.clientid campaign.clientid - json.listingcode campaign.listingcode - json.billingcode campaign.billingcode - json.advertisername campaign.advertisername - json.address1 campaign.address1 - json.address2 campaign.address2 - json.city campaign.city - json.state campaign.state - json.zip campaign.zip - json.emailaddress campaign.emailaddress - json.customerfirstname campaign.customerfirstname - json.customerlastname campaign.customerlastname - json.salesrep campaign.salesrep - json.salesrepemail campaign.salesrepemail - json.businessphone campaign.businessphone - json.contactphone campaign.contactphone - json.websiteurl campaign.websiteurl - json.videolistings campaign.videolistings.each do |videolisting| - json.videocode videolisting.videocode - json.producttypeid videolisting.producttypeid - json.remoteassetsarchive videolisting.remoteassetsarchive - json.voiceoverselection videolisting.voiceoverselection - json.musicselection videolisting.musicselection - json.clientprovidedscript videolisting.clientprovidedscript - json.keywords videolisting.keywords - json.focus videolisting.focus - json.notes videolisting.notes - json.asseturls videolisting.asseturls_array - end + json.partial! 'campaigns/campaign', campaign: campaign end \ No newline at end of file diff --git a/app/views/campaigns/show.json.jbuilder b/app/views/campaigns/show.json.jbuilder index a5da17d..234bf5a 100644 --- a/app/views/campaigns/show.json.jbuilder +++ b/app/views/campaigns/show.json.jbuilder @@ -1,19 +1 @@ -json.campaigns @campaign do |campaign| - json.clientid campaign.clientid - json.listingcode campaign.listingcode - json.billingcode campaign.billingcode - json.advertisername campaign.advertisername - json.address1 campaign.address1 - json.address2 campaign.address2 - json.city campaign.city - json.state campaign.state - json.zip campaign.zip - json.emailaddress campaign.emailaddress - json.customerfirstname campaign.customerfirstname - json.customerlastname campaign.customerlastname - json.salesrep campaign.salesrep - json.salesrepemail campaign.salesrepemail - json.businessphone campaign.businessphone - json.contactphone campaign.contactphone - json.websiteurl campaign.websiteurl -end \ No newline at end of file +json.partial! 'campaigns/campaign', campaign: @campaign diff --git a/db/migrate/20140421145349_add_many_fields_to_campaign.rb b/db/migrate/20140421145349_add_many_fields_to_campaign.rb new file mode 100644 index 0000000..9492310 --- /dev/null +++ b/db/migrate/20140421145349_add_many_fields_to_campaign.rb @@ -0,0 +1,16 @@ +class AddManyFieldsToCampaign < ActiveRecord::Migration + def change + rename_column :campaigns, :address1, :address + remove_column :campaigns, :address2 + add_column :campaigns, :awards, :string + add_column :campaigns, :background, :string + add_column :campaigns, :categories, :string + add_column :campaigns, :companycolors, :string + add_column :campaigns, :description, :string + add_column :campaigns, :facebookurl, :string + add_column :campaigns, :productsandservices, :string + add_column :campaigns, :targetaudience, :string + add_column :campaigns, :tollfreephone, :string + add_column :campaigns, :vpa, :string + end +end diff --git a/db/migrate/20140421150203_add_toneofvideo_to_videolisting.rb b/db/migrate/20140421150203_add_toneofvideo_to_videolisting.rb new file mode 100644 index 0000000..43cce3c --- /dev/null +++ b/db/migrate/20140421150203_add_toneofvideo_to_videolisting.rb @@ -0,0 +1,5 @@ +class AddToneofvideoToVideolisting < ActiveRecord::Migration + def change + add_column :videolistings, :toneofvideo, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 29f2ee5..31ac811 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140415174406) do +ActiveRecord::Schema.define(version: 20140421150203) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -39,8 +39,7 @@ ActiveRecord::Schema.define(version: 20140415174406) do t.string "listingcode" t.string "billingcode" t.string "advertisername" - t.string "address1" - t.string "address2" + t.string "address" t.string "city" t.string "state" t.string "zip" @@ -55,7 +54,17 @@ ActiveRecord::Schema.define(version: 20140415174406) do t.datetime "created_at" t.datetime "updated_at" t.boolean "processed" - t.boolean "sent", default: false + t.boolean "sent", default: false + t.string "awards" + t.string "background" + t.string "categories" + t.string "companycolors" + t.string "description" + t.string "facebookurl" + t.string "productsandservices" + t.string "targetaudience" + t.string "tollfreephone" + t.string "vpa" end create_table "delayed_jobs", force: true do |t| @@ -107,6 +116,7 @@ ActiveRecord::Schema.define(version: 20140415174406) do t.datetime "created_at" t.datetime "updated_at" t.integer "campaign_id" + t.string "toneofvideo" end end