diff --git a/Gemfile b/Gemfile index 079c1bc..ce8f874 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ gem 'jbuilder' gem 'bootstrap-tagsinput-rails' gem 'cocoon', :git => 'git://github.com/nathanvda/cocoon' gem 'zeroclipboard-rails' -gem 'unicorn' +gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 61a476a..c1013cb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: git://github.com/ctran/annotate_models.git + revision: c60fa282d74051e2fb5d41b600f919a39d9edcb4 + specs: + annotate (2.6.3) + activerecord (>= 2.3.0) + rake (>= 0.8.7) + GIT remote: git://github.com/nathanvda/cocoon revision: 3735fecd19199e8331f14ef2056b92de3509ad12 @@ -92,9 +100,11 @@ GEM thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.5) - dotenv (0.10.0) - dotenv-rails (0.10.0) - dotenv (= 0.10.0) + dotenv (0.11.1) + dotenv-deployment (~> 0.0.2) + dotenv-deployment (0.0.2) + dotenv-rails (0.11.1) + dotenv (= 0.11.1) email_validator (1.4.0) activemodel erubis (2.7.0) @@ -128,7 +138,7 @@ GEM mime-types (1.25.1) mini_portile (0.5.3) minitest (5.3.3) - multi_json (1.9.2) + multi_json (1.9.3) nokogiri (1.6.1) mini_portile (~> 0.5.0) orm_adapter (0.5.0) @@ -175,7 +185,7 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - safe_yaml (1.0.2) + safe_yaml (1.0.3) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) @@ -235,6 +245,7 @@ PLATFORMS DEPENDENCIES airbrake + annotate! awesome_print better_errors binding_of_caller diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index a21549d..e59bfec 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -17,7 +17,7 @@ class CampaignsController < ApplicationController end def edit - if @campaign.processed + if @campaign.sent redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign has been submitted, Cannot edit.' end @action = campaign_path(@campaign.listingcode) @@ -39,6 +39,9 @@ class CampaignsController < ApplicationController def update if @campaign.update(campaign_params) + if params[:send] + @campaign.update({sent: true}) + end redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.' else show_errors('edit') diff --git a/app/controllers/videolistings_controller.rb b/app/controllers/videolistings_controller.rb index b875777..788f2ad 100644 --- a/app/controllers/videolistings_controller.rb +++ b/app/controllers/videolistings_controller.rb @@ -4,7 +4,7 @@ class VideolistingsController < ApplicationController def publish if @videolisting.published? @message = "Campaign Already Published." - elsif @videolisting.campaign.processed? + elsif @videolisting.campaign.sent? @videolisting.published = true @videolisting.save diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 9f3f5f8..0d4299b 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -24,7 +24,7 @@ class Campaign < ActiveRecord::Base end def send_to_better_video - if self.processed_changed? && self.processed == true + if self.sent_changed? && self.sent? == true #TODO Make API Calls end end diff --git a/app/views/campaigns/_form.html.erb b/app/views/campaigns/_form.html.erb index e94e4dc..1de2fff 100644 --- a/app/views/campaigns/_form.html.erb +++ b/app/views/campaigns/_form.html.erb @@ -94,6 +94,7 @@
- <%= frm.submit %> + <%= frm.submit "Save For Later", :name => "save" %> + <%= frm.submit "Publish", :name => "send", data: { confirm: 'Once you send to BetterVideo, you cannot edit again. Are you sure?' } %>
<% end %> \ No newline at end of file diff --git a/app/views/campaigns/index.html.erb b/app/views/campaigns/index.html.erb index 2118eb1..ad9da97 100644 --- a/app/views/campaigns/index.html.erb +++ b/app/views/campaigns/index.html.erb @@ -7,7 +7,7 @@ Listing Code (Form Hash) Advertiser - Processed? + Sent? Percent of Videos Completed Address City @@ -22,13 +22,13 @@ <%= link_to campaign.listingcode, campaign_path(campaign.listingcode) %> <%= campaign.advertisername %> - + <%= number_to_percentage(campaign.video_completion_percent, precision: 0) %> <%= campaign.address %> <%= campaign.city %> <%= campaign.state %> <%= campaign.zip %> - <%= link_to 'Edit', edit_campaign_path(campaign.listingcode) %> + <%= link_to 'Edit', edit_campaign_path(campaign.listingcode) unless campaign.sent %> <%= link_to 'Destroy', campaign_path(campaign.listingcode), method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 3cbbfac..470a02c 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -11,12 +11,12 @@ diff --git a/app/views/videolistings/show.html.erb b/app/views/videolistings/show.html.erb index 69a6277..be5017a 100644 --- a/app/views/videolistings/show.html.erb +++ b/app/views/videolistings/show.html.erb @@ -17,9 +17,7 @@ -
-

Preview Image

<%= image_tag(@videolisting.get_preview_url) %> diff --git a/db/migrate/20140429154347_remove_published_from_campaign.rb b/db/migrate/20140429154347_remove_published_from_campaign.rb new file mode 100644 index 0000000..1ce7c78 --- /dev/null +++ b/db/migrate/20140429154347_remove_published_from_campaign.rb @@ -0,0 +1,5 @@ +class RemovePublishedFromCampaign < ActiveRecord::Migration + def change + remove_column :campaigns, :processed + end +end diff --git a/db/schema.rb b/db/schema.rb index 59e74e8..24f0636 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: 20140425201114) do +ActiveRecord::Schema.define(version: 20140429154347) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -51,7 +51,6 @@ ActiveRecord::Schema.define(version: 20140425201114) do t.string "websiteurl" t.datetime "created_at" t.datetime "updated_at" - t.boolean "processed" t.boolean "sent", default: false t.string "awards" t.string "background" diff --git a/spec/controllers/campaigns_controller_spec.rb b/spec/controllers/campaigns_controller_spec.rb index d6975b7..623081b 100644 --- a/spec/controllers/campaigns_controller_spec.rb +++ b/spec/controllers/campaigns_controller_spec.rb @@ -79,9 +79,9 @@ describe CampaignsController do #line 63 camp_controller end - it "doesn't allow edits on an already published campaign" do + it "doesn't allow edits on an already sent campaign" do camp = FactoryGirl.create(:campaign) - camp.processed = true + camp.sent = true camp.save get :edit, listingcode: camp.listingcode expect(response.status).to eq 302 diff --git a/spec/factories/campaigns.rb b/spec/factories/campaigns.rb index d39122f..4053cd6 100644 --- a/spec/factories/campaigns.rb +++ b/spec/factories/campaigns.rb @@ -25,7 +25,7 @@ FactoryGirl.define do vpa "John Smith" websiteurl "bobsbbq.com" zip "90200" - processed false + sent false after(:build) do |campaign, evaluator| video = FactoryGirl.create(:videolisting) campaign.videolistings << video