add migrations, fix the json, using json partials
This commit is contained in:
parent
0d4773a35e
commit
8be8c4142d
12
Gemfile.lock
12
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
|
||||
|
@ -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
|
||||
|
28
app/views/campaigns/_campaign.json.jbuilder
Normal file
28
app/views/campaigns/_campaign.json.jbuilder
Normal file
@ -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
|
10
app/views/campaigns/_videolisting.json.jbuilder
Normal file
10
app/views/campaigns/_videolisting.json.jbuilder
Normal file
@ -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
|
@ -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
|
@ -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
|
||||
json.partial! 'campaigns/campaign', campaign: @campaign
|
||||
|
16
db/migrate/20140421145349_add_many_fields_to_campaign.rb
Normal file
16
db/migrate/20140421145349_add_many_fields_to_campaign.rb
Normal file
@ -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
|
@ -0,0 +1,5 @@
|
||||
class AddToneofvideoToVideolisting < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :videolistings, :toneofvideo, :string
|
||||
end
|
||||
end
|
18
db/schema.rb
18
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
|
||||
|
Loading…
Reference in New Issue
Block a user