diff --git a/app/models/content_configuration.rb b/app/models/content_configuration.rb index 3e1e2b0939..abac92f466 100644 --- a/app/models/content_configuration.rb +++ b/app/models/content_configuration.rb @@ -12,6 +12,20 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration has_attached_file :logo_mobile_svg, default_url: "/assets/ofn-logo-mobile.svg" # Home page + # + # I intended to set a default for home_page_alert_html including I18n text. + # + # default: " + # #{I18n.t('shared.register_call.selling_on_ofn')}  + # #{I18n.t('shared.register_call.register')} + # + # " + # + # Unfortunately, this configuration is initialised and cached before locales + # are loaded. So I chose to not set a default and use a translatable view instead. + # All the following defaults using I18n don't work. + # https://github.com/openfoodfoundation/openfoodnetwork/issues/3816 + preference :home_page_alert_html, :text preference :home_hero, :file preference :home_show_stats, :boolean, default: true has_attached_file :home_hero, default_url: "/assets/home/home.jpg" diff --git a/app/models/preference_sections/home_page_section.rb b/app/models/preference_sections/home_page_section.rb index 05e58c5523..b050322689 100644 --- a/app/models/preference_sections/home_page_section.rb +++ b/app/models/preference_sections/home_page_section.rb @@ -6,6 +6,7 @@ module PreferenceSections def preferences [ + :home_page_alert_html, :home_hero, :home_show_stats ] diff --git a/app/views/shared/_connect_learn_call.html.haml b/app/views/shared/_connect_learn_call.html.haml deleted file mode 100644 index 68152b2b8f..0000000000 --- a/app/views/shared/_connect_learn_call.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -:css - .page-alert .alert-box { background-color: #fdddac; } - -.alert-cta - %h6 - Open Food Network - %strong - = link_to t(:label_connect), "https://openfoodnetwork.org/au/connect/", target: '_blank' - and - %strong - = link_to t(:label_learn), "https://openfoodnetwork.org/au/learn/", target: '_blank' - \- Go exploring and get inspired! diff --git a/app/views/shared/_page_alert.html.haml b/app/views/shared/_page_alert.html.haml index 92def240e7..d57ef18d99 100644 --- a/app/views/shared/_page_alert.html.haml +++ b/app/views/shared/_page_alert.html.haml @@ -1,5 +1,6 @@ -- if feature? :connect_learn_homepage - = render "shared/connect_learn_call" +- if ContentConfig.home_page_alert_html.present? + .alert-cta + %h6= raw ContentConfig.home_page_alert_html - else = render "shared/register_call"