diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index e2c19535..64552508 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -1,4 +1,6 @@ class SubscriptionsController < ApplicationController + before_action :redirect_to_root_if_self_hosted + def new if Current.family.stripe_customer_id.blank? customer = stripe_client.v1.customers.create( @@ -44,4 +46,8 @@ class SubscriptionsController < ApplicationController def stripe_client @stripe_client ||= Stripe::StripeClient.new(ENV["STRIPE_SECRET_KEY"]) end + + def redirect_to_root_if_self_hosted + redirect_to root_path, alert: I18n.t("subscriptions.self_hosted_alert") if self_hosted? + end end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 0eaecd85..e15414a5 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -4,7 +4,7 @@ module SettingsHelper { name: I18n.t("settings.settings_nav.preferences_label"), path: :settings_preferences_path }, { name: I18n.t("settings.settings_nav.security_label"), path: :settings_security_path }, { name: I18n.t("settings.settings_nav.self_hosting_label"), path: :settings_hosting_path, condition: :self_hosted? }, - { name: I18n.t("settings.settings_nav.billing_label"), path: :settings_billing_path }, + { name: I18n.t("settings.settings_nav.billing_label"), path: :settings_billing_path, condition: :not_self_hosted? }, { name: I18n.t("settings.settings_nav.accounts_label"), path: :accounts_path }, { name: I18n.t("settings.settings_nav.imports_label"), path: :imports_path }, { name: I18n.t("settings.settings_nav.tags_label"), path: :tags_path }, @@ -45,4 +45,9 @@ module SettingsHelper concat(next_setting) end end + + private + def not_self_hosted? + !self_hosted? + end end diff --git a/app/views/settings/_settings_nav.html.erb b/app/views/settings/_settings_nav.html.erb index 1934d921..632e774c 100644 --- a/app/views/settings/_settings_nav.html.erb +++ b/app/views/settings/_settings_nav.html.erb @@ -32,10 +32,11 @@ <%= render "settings/settings_nav_item", name: t(".self_hosting_label"), path: settings_hosting_path, icon: "database" %> <% end %> - -