mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Moving shopfront trial progress bar logic into enterprises helper and dealing with expiry
This commit is contained in:
@@ -45,4 +45,20 @@ module EnterprisesHelper
|
||||
options[:data] = { :action => 'remove', :confirm => enterprise_confirm_delete_message(enterprise) }
|
||||
link_to_with_icon 'icon-trash', name, url, options
|
||||
end
|
||||
|
||||
def shop_trial_in_progress?(enterprise)
|
||||
!!enterprise.shop_trial_start_date &&
|
||||
(enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days > Time.now) &&
|
||||
%w(own any).include?(enterprise.sells)
|
||||
end
|
||||
|
||||
def shop_trial_expired?(enterprise)
|
||||
!!enterprise.shop_trial_start_date &&
|
||||
(enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days <= Time.now) &&
|
||||
%w(own any).include?(enterprise.sells)
|
||||
end
|
||||
|
||||
def remaining_trial_days(enterprise)
|
||||
distance_of_time_in_words(Time.now, enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -285,16 +285,6 @@ class Enterprise < ActiveRecord::Base
|
||||
shipping_methods.any? && payment_methods.available.any?
|
||||
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
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
- 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
|
||||
= render 'spree/admin/shared/trial_progress_bar', enterprise: enterprise
|
||||
@@ -1,2 +1,7 @@
|
||||
#trial_progress_bar
|
||||
= "Your shopfront trial expires in #{enterprise.remaining_trial_days}."
|
||||
- if enterprise
|
||||
-if shop_trial_in_progress?(enterprise)
|
||||
#trial_progress_bar
|
||||
= "Your shopfront trial expires in #{remaining_trial_days(enterprise)}."
|
||||
-elsif shop_trial_expired?(enterprise)
|
||||
#trial_progress_bar
|
||||
= "Good news! We have decided to extend shopfront trials until further notice (probably around March 2015)."
|
||||
Reference in New Issue
Block a user