Adding trial progress bar

This commit is contained in:
Rob Harrington
2014-10-24 12:32:05 +11:00
parent f40b4d9d03
commit d0c3502f27
5 changed files with 33 additions and 6 deletions

View File

@@ -0,0 +1,8 @@
#trial_progress_bar
position: fixed
bottom: 0px
width: 100%
padding: 8px 10px
font-weight: bold
background-color: #5498da
color: white

View File

@@ -10,7 +10,7 @@ module EnterprisesHelper
def managed_enterprises
Enterprise.managed_by(spree_current_user)
end
def enterprises_options enterprises
enterprises.map { |enterprise| [enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city, enterprise.id.to_i] }
end
@@ -20,13 +20,13 @@ module EnterprisesHelper
end
def enterprise_type_name(enterprise)
# TODO: When we can distinguish between profiles and producers that supply only (without
# their own store), include it here.
# profile, supplier only, shopfront
enterprise.sells == 'none' ? 'profile' : 'shopfront'
if enterprise.sells == 'none'
enterprise.producer_profile_only ? 'Profile' : 'Supplier Only'
else
"Has Shopfront"
end
end
def enterprise_confirm_delete_message(enterprise)
if enterprise.supplied_products.present?
"This will also delete the #{pluralize enterprise.supplied_products.count, 'product'} that this enterprise supplies. Are you sure you want to continue?"

View File

@@ -1,5 +1,6 @@
class Enterprise < ActiveRecord::Base
SELLS = %w(unspecified none own any)
SHOP_TRIAL_LENGTH = 30
ENTERPRISE_SEARCH_RADIUS = 100
devise :confirmable, reconfirmable: true
@@ -259,6 +260,16 @@ class Enterprise < ActiveRecord::Base
select('DISTINCT spree_taxons.*')
end
def shop_trial_in_progress?
!!shop_trial_start_date &&
(shop_trial_start_date + SHOP_TRIAL_LENGTH.days > Time.now) &&
%w(own any).include?(sells)
end
def remaining_trial_days
distance_of_time_in_words(Time.now, shop_trial_start_date + SHOP_TRIAL_LENGTH.days)
end
protected
def devise_mailer

View File

@@ -0,0 +1,6 @@
/ insert_top "[data-hook='admin_footer_scripts']"
- enterprise = spree_current_user.enterprises.first if OpenFoodNetwork::Permissions.new(spree_current_user).manages_one_enterprise?
- if enterprise && enterprise.shop_trial_in_progress?
= render 'spree/admin/shared/trial_progress_bar', enterprise: enterprise

View File

@@ -0,0 +1,2 @@
#trial_progress_bar
= "Your shopfront trial expires in #{enterprise.remaining_trial_days}."