Module: Decidim::Toggle::SystemSettingsTabHelper
- Defined in:
- app/helpers/decidim/toggle/system_settings_tab_helper.rb
Instance Method Summary collapse
- #decidim_toggle_settings_tab_form(organization, tab, &block) ⇒ Object
- #decidim_toggle_update_settings_tab_organization_path(organization, tab_id:) ⇒ Object
-
#encryption_configured? ⇒ Boolean
Check if Decidim can use encryption.
Instance Method Details
#decidim_toggle_settings_tab_form(organization, tab, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/decidim/toggle/system_settings_tab_helper.rb', line 28 def decidim_toggle_settings_tab_form(organization, tab, &block) tab_form = tab.form_class.from_model(organization) if (stored = flash[:decidim_toggle_invalid_settings_tab]) && stored[:organization_id].to_i == organization.id && stored[:tab_id].to_s == tab.identifier.to_s flash.delete(:decidim_toggle_invalid_settings_tab) tab_form = tab.form_class.from_params(organization: stored[:params]) tab_form = tab_form.with_context(current_organization: organization) if tab_form.respond_to?(:with_context) stored[:errors].each do |attribute, | .each { || tab_form.errors.add(attribute, ) } end end form_with( url: decidim_toggle_update_settings_tab_organization_path(organization, tab_id: tab.identifier), model: tab_form, scope: :organization, builder: Decidim::Toggle::SettingsFormBuilder, method: :patch, html: { id: "settings_tab_form_#{tab.identifier}" }, local: true ) do |tf| safe_join([ render("decidim_toggle/system/organizations/settings_tab_active_tab_field", tab:), tf.informative_callouts, content_tag(:div, class: "form__wrapper") { capture(tf, &block) }, render("decidim_toggle/system/organizations/settings_tab_submit", form: tf) ]) end end |
#decidim_toggle_update_settings_tab_organization_path(organization, tab_id:) ⇒ Object
22 23 24 25 26 |
# File 'app/helpers/decidim/toggle/system_settings_tab_helper.rb', line 22 def decidim_toggle_update_settings_tab_organization_path(organization, tab_id:) path = Decidim::Toggle::Engine.routes.url_helpers.update_settings_tab_organization_path(organization, tab_id:) prefixed = path.start_with?("/decidim_toggle") ? path : "/decidim_toggle#{path}" prefixed.sub(%r{\A/decidim_toggle/decidim_toggle}, "/decidim_toggle") end |
#encryption_configured? ⇒ Boolean
Check if Decidim can use encryption
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/decidim/toggle/system_settings_tab_helper.rb', line 8 def encryption_configured? return false if Rails.application.secret_key_base.blank? probe = "decidim-toggle-secret-probe" encrypted = Decidim::AttributeEncryptor.encrypt(probe) return false if encrypted.blank? Decidim::AttributeEncryptor.decrypt(encrypted) == probe rescue ArgumentError, OpenSSL::Cipher::CipherError, ActiveSupport::MessageEncryptor::InvalidMessage, ActiveSupport::MessageVerifier::InvalidSignature false end |