Add config setting to enable/disable stats on home page

This commit is contained in:
Rohan Mitchell
2015-07-10 17:35:51 +10:00
parent 1f72e4001c
commit 5de9a5eb54
5 changed files with 26 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@preference_sections = [{name: 'Home page', preferences: [:home_tagline_cta, :home_whats_happening]},
@preference_sections = [{name: 'Home page', preferences: [:home_tagline_cta, :home_whats_happening, :home_show_stats]},
{name: 'Producer signup page', preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
{name: 'Hub signup page', preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
{name: 'Group signup page', preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},

View File

@@ -2,9 +2,11 @@ class HomeController < BaseController
layout 'darkswarm'
def index
@num_distributors = Enterprise.is_distributor.activated.visible.count
@num_producers = Enterprise.is_primary_producer.activated.visible.count
@num_users = Spree::User.joins(:orders).merge(Spree::Order.complete).count('DISTINCT spree_users.*')
@num_orders = Spree::Order.complete.count
if ContentConfig.home_show_stats
@num_distributors = Enterprise.is_distributor.activated.visible.count
@num_producers = Enterprise.is_primary_producer.activated.visible.count
@num_users = Spree::User.joins(:orders).merge(Spree::Order.complete).count('DISTINCT spree_users.*')
@num_orders = Spree::Order.complete.count
end
end
end

View File

@@ -2,6 +2,7 @@ class ContentConfiguration < Spree::Preferences::Configuration
# Home page
preference :home_tagline_cta, :string, default: "Browse Open Food Network Australia"
preference :home_whats_happening, :string, default: "Thanks for making the Open Food Network possible. Our vision is a better food system, and we're proud of what we're achieving together."
preference :home_show_stats, :boolean, default: true
# Producer sign-up page
preference :producer_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"

View File

@@ -4,19 +4,20 @@
%h2 We're creating a new food system.
.row.content
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_producers
food producers
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_distributors
food shops
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_users
food shoppers
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_orders
food orders
- if ContentConfig.home_show_stats
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_producers
food producers
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_distributors
food shops
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_users
food shoppers
.small-12.medium-3.columns.text-center
%h4
%strong= number_with_delimiter @num_orders
food orders

View File

@@ -20,6 +20,7 @@ en:
producers_join: Australian producers are now welcome to join the Open Food Network.
charges_sales_tax: Charges GST?
home_show_stats: "Show statistics"
home_tagline_cta: "Tagline call to action"
home_whats_happening: "What's happening"
footer_facebook_url: "Facebook URL"