Permalink
Browse files

enable/disable saved_searches & watch_projects

  • Loading branch information...
1 parent 9138c34 commit 3e0bac07fe3a1df4bc65f196db386fa3c5d69fa9 @ajb ajb committed Apr 6, 2013
@@ -69,6 +69,8 @@ def authorize!
end
def global_config_params
- params.require(:global_config).permit(:bid_review_enabled, :bid_submission_enabled, :comments_enabled, :questions_enabled, :amendments_enabled)
+ params.require(:global_config)
+ .permit(:bid_review_enabled, :bid_submission_enabled, :comments_enabled, :questions_enabled, :amendments_enabled,
+ :watch_projects_enabled, :save_searches_enabled, :search_projects_enabled)
end
end
@@ -1,6 +1,7 @@
class SavedSearchesController < ApplicationController
before_filter :authenticate_vendor!
before_filter :saved_search_exists?, only: :destroy
+ before_filter { |c| c.check_enabled!('save_searches') }
def index
@saved_searches = current_vendor.saved_searches.paginate(page: params[:page])
@@ -2,6 +2,7 @@ class WatchesController < ApplicationController
before_filter :authenticate_user!, only: :post
before_filter :authenticate_vendor!, only: :vendor_projects
before_filter :load_and_authorize_watchable!, only: :post
+ before_filter only: [:vendor_projects] { |c| c.check_enabled!('watch_projects') }
def post
current_user.send(current_user.watches?(params[:watchable_type], params[:watchable_id]) ? :unwatch! : :watch!,
@@ -2,15 +2,18 @@
#
# Table name: global_configs
#
-# id :integer not null, primary key
-# bid_review_enabled :boolean default(TRUE)
-# bid_submission_enabled :boolean default(TRUE)
-# comments_enabled :boolean default(TRUE)
-# questions_enabled :boolean default(TRUE)
-# event_hooks :text
-# created_at :datetime not null
-# updated_at :datetime not null
-# amendments_enabled :boolean default(TRUE)
+# id :integer not null, primary key
+# bid_review_enabled :boolean default(TRUE)
+# bid_submission_enabled :boolean default(TRUE)
+# comments_enabled :boolean default(TRUE)
+# questions_enabled :boolean default(TRUE)
+# event_hooks :text
+# created_at :datetime not null
+# updated_at :datetime not null
+# amendments_enabled :boolean default(TRUE)
+# watch_projects_enabled :boolean default(TRUE)
+# save_searches_enabled :boolean default(TRUE)
+# search_projects_enabled :boolean default(TRUE)
#
require_dependency 'enum'
@@ -28,6 +28,21 @@
= f.check_box :amendments_enabled
Amendments
+ %label.checkbox
+ .switch
+ = f.check_box :watch_projects_enabled
+ Watch Projects
+
+ %label.checkbox
+ .switch
+ = f.check_box :save_searches_enabled
+ Save Searches
+
+ %label.checkbox
+ .switch
+ = f.check_box :search_projects_enabled
+ Fancy projects page
+
%h4 Event Hooks
.row-fluid
@@ -22,10 +22,12 @@
%li
=link_to "My Projects", mine_projects_path
- elsif vendor_signed_in?
- %li
- =link_to "Watched Projects", vendor_projects_watches_path
- %li
- =link_to "Saved Searches", saved_searches_path
+ - if GlobalConfig.instance[:watch_projects_enabled]
+ %li
+ =link_to "Watched Projects", vendor_projects_watches_path
+ - if GlobalConfig.instance[:save_searches_enabled]
+ %li
+ =link_to "Saved Searches", saved_searches_path
%li
=link_to "Settings", settings_path
@@ -0,0 +1,7 @@
+class AddMoreOnOffToGlobalConfigs < ActiveRecord::Migration
+ def change
+ add_column :global_configs, :watch_projects_enabled, :boolean, default: true
+ add_column :global_configs, :save_searches_enabled, :boolean, default: true
+ add_column :global_configs, :search_projects_enabled, :boolean, default: true
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130406004215) do
+ActiveRecord::Schema.define(:version => 20130406004710) do
create_table "amendments", :force => true do |t|
t.integer "project_id"
@@ -126,14 +126,17 @@
end
create_table "global_configs", :force => true do |t|
- t.boolean "bid_review_enabled", :default => true
- t.boolean "bid_submission_enabled", :default => true
- t.boolean "comments_enabled", :default => true
- t.boolean "questions_enabled", :default => true
+ t.boolean "bid_review_enabled", :default => true
+ t.boolean "bid_submission_enabled", :default => true
+ t.boolean "comments_enabled", :default => true
+ t.boolean "questions_enabled", :default => true
t.text "event_hooks"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "amendments_enabled", :default => true
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "amendments_enabled", :default => true
+ t.boolean "watch_projects_enabled", :default => true
+ t.boolean "save_searches_enabled", :default => true
+ t.boolean "search_projects_enabled", :default => true
end
create_table "impressions", :force => true do |t|
@@ -2,6 +2,11 @@ namespace :send_saved_search_emails do
desc "send all emails"
task all: :environment do
+ if !GlobalConfig.instance[:save_searches_enabled]
+ puts "Saved searches are not enabled for your app."
+ next
+ end
+
Vendor.all.each do |vendor|
SavedSearchMailer.search_email(vendor).deliver
end
@@ -2,15 +2,18 @@
#
# Table name: global_configs
#
-# id :integer not null, primary key
-# bid_review_enabled :boolean default(TRUE)
-# bid_submission_enabled :boolean default(TRUE)
-# comments_enabled :boolean default(TRUE)
-# questions_enabled :boolean default(TRUE)
-# event_hooks :text
-# created_at :datetime not null
-# updated_at :datetime not null
-# amendments_enabled :boolean default(TRUE)
+# id :integer not null, primary key
+# bid_review_enabled :boolean default(TRUE)
+# bid_submission_enabled :boolean default(TRUE)
+# comments_enabled :boolean default(TRUE)
+# questions_enabled :boolean default(TRUE)
+# event_hooks :text
+# created_at :datetime not null
+# updated_at :datetime not null
+# amendments_enabled :boolean default(TRUE)
+# watch_projects_enabled :boolean default(TRUE)
+# save_searches_enabled :boolean default(TRUE)
+# search_projects_enabled :boolean default(TRUE)
#
require 'spec_helper'

0 comments on commit 3e0bac0

Please sign in to comment.