From 0e6f823154a8929fe9505c0682eaaf7e95cb8bdf Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 25 Feb 2015 13:49:18 -0600 Subject: [PATCH] toggle whether a donation campaign is advertised --- app/helpers/application_helper.rb | 6 ++++++ app/views/layouts/items.html.haml | 2 +- app/views/outfits/new.html.haml | 2 +- app/views/outfits/show.html.haml | 2 +- .../20150225194522_add_advertised_to_campaign.rb | 5 +++++ db/schema.rb | 13 +++++++------ 6 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20150225194522_add_advertised_to_campaign.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 71cb5d1a..8a03577b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -20,6 +20,12 @@ module ApplicationHelper end end + def advertise_campaign_progress(campaign, &block) + if campaign && campaign.advertised? + campaign_progress(campaign, &block) + end + end + def campaign_progress(campaign, &block) if campaign if block_given? diff --git a/app/views/layouts/items.html.haml b/app/views/layouts/items.html.haml index 917f5033..b609a23d 100644 --- a/app/views/layouts/items.html.haml +++ b/app/views/layouts/items.html.haml @@ -1,4 +1,4 @@ -- content_for :before_title, campaign_progress(@campaign) +- content_for :before_title, advertise_campaign_progress(@campaign) - content_for :title_category do #{t 'infinite_closet'}: #{t '.title_tagline'} - content_for :before_flashes do diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index ddd39ca8..cdba9664 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -1,6 +1,6 @@ - hide_home_link -= campaign_progress @campaign += advertise_campaign_progress @campaign %p#pet-not-found.alert= t 'pets.load.not_found' %p#neopia-error.alert= t 'pets.load.neopia_error' diff --git a/app/views/outfits/show.html.haml b/app/views/outfits/show.html.haml index 71166ecd..3bae9a3a 100644 --- a/app/views/outfits/show.html.haml +++ b/app/views/outfits/show.html.haml @@ -1,5 +1,5 @@ - title(@outfit.name || t('.default_outfit_name')) -- content_for :before_title, campaign_progress(@campaign) +- content_for :before_title, advertise_campaign_progress(@campaign) - open_graph :type => 'openneo-impress:outfit', :title => yield(:title), :url => outfit_url(@outfit) diff --git a/db/migrate/20150225194522_add_advertised_to_campaign.rb b/db/migrate/20150225194522_add_advertised_to_campaign.rb new file mode 100644 index 00000000..a82068c4 --- /dev/null +++ b/db/migrate/20150225194522_add_advertised_to_campaign.rb @@ -0,0 +1,5 @@ +class AddAdvertisedToCampaign < ActiveRecord::Migration + def change + add_column :campaigns, :advertised, :boolean, null: false, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index f4e32d88..2147294d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140910204043) do +ActiveRecord::Schema.define(:version => 20150225194522) do create_table "auth_servers", :force => true do |t| t.string "short_name", :limit => 10, :null => false @@ -33,11 +33,12 @@ ActiveRecord::Schema.define(:version => 20140910204043) do add_index "campaign_translations", ["locale"], :name => "index_campaign_translations_on_locale" create_table "campaigns", :force => true do |t| - t.integer "progress", :null => false - t.integer "goal", :null => false - t.boolean "active", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "progress", :null => false + t.integer "goal", :null => false + t.boolean "active", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "advertised", :default => true, :null => false end create_table "campaigns_old", :force => true do |t|