From 0501db1782934d8c48db04cbd7cee6e713199cb2 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 21 Feb 2019 22:40:23 +0000 Subject: [PATCH] Remove changes related to enterprise trials as they dont make sense without business models and account invoices --- .../admin/components/trial_progess_bar.scss | 12 --- .../admin/enterprises_controller.rb | 4 - app/helpers/enterprises_helper.rb | 16 ---- app/models/enterprise.rb | 4 - .../enterprises/_change_type_form.html.haml | 15 +--- app/views/shops/signup.html.haml | 3 - .../single_enterprise_dashboard.html.haml | 2 - .../shared/_trial_progress_bar.html.haml | 7 -- config/locales/en.yml | 14 --- ...2_drop_enterprise_shop_trial_start_date.rb | 9 ++ db/schema.rb | 3 +- .../admin/enterprises_controller_spec.rb | 90 +++---------------- 12 files changed, 21 insertions(+), 158 deletions(-) delete mode 100644 app/assets/stylesheets/admin/components/trial_progess_bar.scss delete mode 100644 app/views/spree/admin/shared/_trial_progress_bar.html.haml create mode 100644 db/migrate/20190221214542_drop_enterprise_shop_trial_start_date.rb diff --git a/app/assets/stylesheets/admin/components/trial_progess_bar.scss b/app/assets/stylesheets/admin/components/trial_progess_bar.scss deleted file mode 100644 index bfcc743c58..0000000000 --- a/app/assets/stylesheets/admin/components/trial_progess_bar.scss +++ /dev/null @@ -1,12 +0,0 @@ -@import "../variables"; - -#trial_progress_bar { - position: fixed; - left: 0px; - bottom: 0px; - width: 100vw; - padding: 8px 10px; - font-weight: bold; - background-color: $spree-blue; - color: white; -} diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index 11dd547042..c59f610436 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -64,10 +64,6 @@ module Admin attributes = { sells: params[:sells], visible: true } - if ['own', 'any'].include? params[:sells] - attributes[:shop_trial_start_date] = @enterprise.shop_trial_start_date || Time.zone.now - end - if @enterprise.update_attributes(attributes) flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name) redirect_to admin_path diff --git a/app/helpers/enterprises_helper.rb b/app/helpers/enterprises_helper.rb index e1b85fc14b..899d6156bb 100644 --- a/app/helpers/enterprises_helper.rb +++ b/app/helpers/enterprises_helper.rb @@ -78,22 +78,6 @@ module EnterprisesHelper 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 + Spree::Config[:shop_trial_length_days].days > Time.zone.now) && - %w(own any).include?(enterprise.sells) - end - - def shop_trial_expired?(enterprise) - !!enterprise.shop_trial_start_date && - (enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days <= Time.zone.now) && - %w(own any).include?(enterprise.sells) - end - - def remaining_trial_days(enterprise) - distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days) - end - def order_changes_allowed? current_order.andand.distributor.andand.allow_order_changes? end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 26f45ad503..2e4bc66fcd 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -321,10 +321,6 @@ class Enterprise < ActiveRecord::Base end end - def shop_trial_expiry - shop_trial_start_date.andand + Spree::Config[:shop_trial_length_days].days - end - def can_invoice? abn.present? end diff --git a/app/views/admin/enterprises/_change_type_form.html.haml b/app/views/admin/enterprises/_change_type_form.html.haml index dfaebabf0d..687ee3af3b 100644 --- a/app/views/admin/enterprises/_change_type_form.html.haml +++ b/app/views/admin/enterprises/_change_type_form.html.haml @@ -42,12 +42,6 @@ %p.description = t('.producer_hub_description_text') - -# %p.description - -# Test out having your own shopfront with full access to all Shopfront features for 30 days. - -# %br - -# %br - -# At the end of your trial, there is a one-off $200 fee to fully activate your account. Then you will be billed for 2% of your actual transactions, capped at $50 a month (so if you don’t sell anything you don’t pay anything, but you never pay more than $50 a month). - - else .two.columns.alpha   @@ -76,14 +70,7 @@ .sixteen.columns.alpha %span.error{ ng: { show: "(change_type.sells.$error.required || change_type.sells.$error.pattern) && submitted" } } = t('.choose_option') - - if @enterprise.sells == 'unspecified' && @enterprise.shop_trial_start_date.nil? - -if free_use? - %input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)" } } - - else - - trial_length = Spree::Config[:shop_trial_length_days] - %input.button.big{ type: 'submit', value: "Start #{trial_length}-Day Shop Trial", ng: { click: "submit(change_type)", show: "sells=='own' || sells=='any'" } } - %input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)", hide: "sells=='own' || sells=='any'" } } - - elsif @enterprise.sells == 'unspecified' + - if @enterprise.sells == 'unspecified' %input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)" } } - else %input.button.big{ type: 'submit', value: t('.change_now'), ng: { click: "submit(change_type)" } } diff --git a/app/views/shops/signup.html.haml b/app/views/shops/signup.html.haml index fd8dc3a0da..72f63a0dca 100644 --- a/app/views/shops/signup.html.haml +++ b/app/views/shops/signup.html.haml @@ -19,9 +19,6 @@ .small-12.medium-10.medium-offset-1.columns.text-center %h2 = t :shops_signup_pricing - -# %p.text-big - -# If there is a time-sensitive offer you can write it here, e.g. - -# Sign up before 30th June for an extra month free! %br = ContentConfig.hub_signup_pricing_table_html.html_safe diff --git a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml index dac3df1b8f..caa8e925c4 100644 --- a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml +++ b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml @@ -89,5 +89,3 @@ %a.button.bottom{href: main_app.admin_order_cycles_path} = t "manage_order_cycles" %span.icon-arrow-right - -= render 'spree/admin/shared/trial_progress_bar', enterprise: @enterprise diff --git a/app/views/spree/admin/shared/_trial_progress_bar.html.haml b/app/views/spree/admin/shared/_trial_progress_bar.html.haml deleted file mode 100644 index 4c76e40705..0000000000 --- a/app/views/spree/admin/shared/_trial_progress_bar.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- if enterprise - -if shop_trial_in_progress?(enterprise) - #trial_progress_bar - = "#{t(:shop_trial_expires_in)} #{remaining_trial_days(enterprise)}." - -elsif shop_trial_expired?(enterprise) - #trial_progress_bar - = t(:shop_trial_expired_notice) diff --git a/config/locales/en.yml b/config/locales/en.yml index b2be034d58..d9c3f67b48 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -202,17 +202,9 @@ en: confirm_resend_order_confirmation: "Are you sure you want to resend the order confirmation email?" must_have_valid_business_number: "%{enterprise_name} must have a valid ABN before invoices can be sent." invoice: "Invoice" - percentage_of_sales: "%{percentage} of sales" - capped_at_cap: "capped at %{cap}" - per_month: "per month" - free: "free" - free_trial: "free trial" - plus_tax: "plus GST" - min_bill_turnover_desc: "once turnover exceeds %{mbt_amount}" more: "More" say_no: "No" say_yes: "Yes" - then: then ongoing: Ongoing bill_address: Billing Address ship_address: Shipping Address @@ -1767,10 +1759,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using products_distributor_info: When you select a distributor for your order, their address and pickup times will be displayed here. products_distribution_adjustment_label: "Product distribution by %{distributor} for %{product}" - shop_trial_expires_in: "Your shopfront trial expires in" - shop_trial_expired_notice: "Good news! We have decided to extend shopfront trials until further notice." - - # keys used in javascript password: Password remember_me: Remember Me @@ -2154,7 +2142,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using live: "live" manage: "Manage" resend: "Resend" - trial: Trial add_and_manage_products: "Add & manage products" add_and_manage_order_cycles: "Add & manage order cycles" manage_order_cycles: "Manage order cycles" @@ -2187,7 +2174,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using hub_sidebar_at_least: "At least one hub must be selected" hub_sidebar_blue: "blue" hub_sidebar_red: "red" - shop_trial_in_progress: "Your shopfront trial expires in %{days}." report_customers_distributor: "Distributor" report_customers_supplier: "Supplier" report_customers_cycle: "Order Cycle" diff --git a/db/migrate/20190221214542_drop_enterprise_shop_trial_start_date.rb b/db/migrate/20190221214542_drop_enterprise_shop_trial_start_date.rb new file mode 100644 index 0000000000..69dd360e2c --- /dev/null +++ b/db/migrate/20190221214542_drop_enterprise_shop_trial_start_date.rb @@ -0,0 +1,9 @@ +class DropEnterpriseShopTrialStartDate < ActiveRecord::Migration + def up + remove_column :enterprises, :shop_trial_start_date + end + + def down + add_column :enterprises, :shop_trial_start_date, :datetime, default: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 0f3f29f08c..6e4426e2bb 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 => 20190221131741) do +ActiveRecord::Schema.define(:version => 20190221214542) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false @@ -233,7 +233,6 @@ ActiveRecord::Schema.define(:version => 20190221131741) do t.string "linkedin" t.integer "owner_id", :null => false t.string "sells", :default => "none", :null => false - t.datetime "shop_trial_start_date" t.boolean "producer_profile_only", :default => false t.string "permalink", :null => false t.boolean "charges_sales_tax", :default => false, :null => false diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index f95bc6e8da..5c9fbea31a 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -344,90 +344,20 @@ module Admin enterprise.save! end - context "if the trial has finished" do - let(:trial_start) { 30.days.ago.beginning_of_day } - - before do - enterprise.update_attribute(:shop_trial_start_date, trial_start) - end - - it "is allowed" do - Timecop.freeze(Time.zone.local(2015, 4, 16, 14, 0, 0)) do - spree_post :register, { id: enterprise, sells: 'own' } - expect(response).to redirect_to spree.admin_path - expect(enterprise.reload.sells).to eq 'own' - expect(enterprise.shop_trial_start_date).to eq trial_start - end - end - end - - context "if the trial has not finished" do - let(:trial_start) { Date.current.to_time } - - before do - enterprise.update_attribute(:shop_trial_start_date, trial_start) - end - - it "is allowed, but trial start date is not reset" do - spree_post :register, { id: enterprise, sells: 'own' } - expect(response).to redirect_to spree.admin_path - expect(enterprise.reload.sells).to eq 'own' - expect(enterprise.shop_trial_start_date).to eq trial_start - end - end - - context "if a trial has not started" do - it "is allowed" do - spree_post :register, { id: enterprise, sells: 'own' } - expect(response).to redirect_to spree.admin_path - expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!" - expect(enterprise.reload.sells).to eq 'own' - expect(enterprise.reload.shop_trial_start_date).to be > Time.zone.now-(1.minute) - end + it "is allowed" do + spree_post :register, { id: enterprise, sells: 'own' } + expect(response).to redirect_to spree.admin_path + expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!" + expect(enterprise.reload.sells).to eq 'own' end end context "setting 'sells' to any" do - context "if the trial has finished" do - let(:trial_start) { 30.days.ago.beginning_of_day } - - before do - enterprise.update_attribute(:shop_trial_start_date, trial_start) - end - - it "is allowed" do - Timecop.freeze(Time.zone.local(2015, 4, 16, 14, 0, 0)) do - spree_post :register, { id: enterprise, sells: 'any' } - expect(response).to redirect_to spree.admin_path - expect(enterprise.reload.sells).to eq 'any' - expect(enterprise.shop_trial_start_date).to eq trial_start - end - end - end - - context "if the trial has not finished" do - let(:trial_start) { Date.current.to_time } - - before do - enterprise.update_attribute(:shop_trial_start_date, trial_start) - end - - it "is allowed, but trial start date is not reset" do - spree_post :register, { id: enterprise, sells: 'any' } - expect(response).to redirect_to spree.admin_path - expect(enterprise.reload.sells).to eq 'any' - expect(enterprise.shop_trial_start_date).to eq trial_start - end - end - - context "if a trial has not started" do - it "is allowed" do - spree_post :register, { id: enterprise, sells: 'any' } - expect(response).to redirect_to spree.admin_path - expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!" - expect(enterprise.reload.sells).to eq 'any' - expect(enterprise.reload.shop_trial_start_date).to be > Time.zone.now-(1.minute) - end + it "is allowed" do + spree_post :register, { id: enterprise, sells: 'any' } + expect(response).to redirect_to spree.admin_path + expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!" + expect(enterprise.reload.sells).to eq 'any' end end