Module: Decidim::DecidimAwesome::AwesomeHelpers
- Includes:
- RequestMemoizer
- Included in:
- AdminEngine, Engine, Proposals::ProposalVotesControllerOverride
- Defined in:
- lib/decidim/decidim_awesome/awesome_helpers.rb
Instance Method Summary collapse
-
#awesome_authorizations_for(user) ⇒ Object
Retrieves all the “admins_available_authorizations” for the user along with other possible authorizations returns an instance of Decidim::DecidimAwesome::Authorizer.
- #awesome_config ⇒ Object
-
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url.
-
#awesome_force_authorizations ⇒ Object
Collects all the force authorizations that is applied in the current URL context.
-
#awesome_proposal_custom_fields ⇒ Object
Collects all proposal custom fields that is applied in the current URL context.
- #awesome_proposal_private_custom_fields ⇒ Object
-
#awesome_scoped_admin_styles ⇒ Object
Collects all CSS that is applied in the current URL context.
-
#awesome_scoped_admins ⇒ Object
Collects all proposal custom fields that is applied in the current URL context.
-
#awesome_scoped_styles ⇒ Object
Collects all CSS that is applied in the current URL context.
- #awesome_version ⇒ Object
-
#awesome_voting_manifest_for(component) ⇒ Object
this will check if the current component has been configured to use a custom voting manifest.
- #javascript_config_vars ⇒ Object
- #organization_awesome_config ⇒ Object
- #show_public_intergram? ⇒ Boolean
- #unfiltered_awesome_config ⇒ Object
- #version_prefix ⇒ Object
Methods included from RequestMemoizer
Instance Method Details
#awesome_authorizations_for(user) ⇒ Object
Retrieves all the “admins_available_authorizations” for the user along with other possible authorizations returns an instance of Decidim::DecidimAwesome::Authorizer
107 108 109 110 111 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 107 def (user) memoize("awesome_authorizations_for_#{user.id}") do Authorizer.new(user, awesome_config[:admins_available_authorizations]) end end |
#awesome_config ⇒ Object
22 23 24 25 26 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 22 def awesome_config memoize("awesome_config") do awesome_config_instance.config end end |
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url
12 13 14 15 16 17 18 19 20 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 12 def awesome_config_instance @awesome_config_instance ||= memoize("current_config") do config = Config.new(request.env["decidim.current_organization"]) config.context_from_request!(request) config end @awesome_config_instance.application_context!(current_user:) if respond_to?(:current_user) @awesome_config_instance end |
#awesome_force_authorizations ⇒ Object
Collects all the force authorizations that is applied in the current URL context
92 93 94 95 96 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 92 def memoize("awesome_force_authorizations") do awesome_config_instance.collect_sub_configs_values("force_authorization") end end |
#awesome_proposal_custom_fields ⇒ Object
Collects all proposal custom fields that is applied in the current URL context
79 80 81 82 83 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 79 def awesome_proposal_custom_fields memoize("awesome_proposal_custom_fields") do awesome_config_instance.collect_sub_configs_values("proposal_custom_field") end end |
#awesome_proposal_private_custom_fields ⇒ Object
85 86 87 88 89 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 85 def awesome_proposal_private_custom_fields memoize("awesome_proposal_private_custom_fields") do awesome_config_instance.collect_sub_configs_values("proposal_private_custom_field") end end |
#awesome_scoped_admin_styles ⇒ Object
Collects all CSS that is applied in the current URL context
65 66 67 68 69 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 65 def awesome_scoped_admin_styles memoize("awesome_scoped_admin_styles") do awesome_config_instance.collect_sub_configs_values("scoped_admin_style") end end |
#awesome_scoped_admins ⇒ Object
Collects all proposal custom fields that is applied in the current URL context
72 73 74 75 76 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 72 def awesome_scoped_admins memoize("awesome_scoped_admins") do awesome_config_instance.collect_sub_configs_values("scoped_admin") end end |
#awesome_scoped_styles ⇒ Object
Collects all CSS that is applied in the current URL context
58 59 60 61 62 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 58 def awesome_scoped_styles memoize("awesome_scoped_styles") do awesome_config_instance.collect_sub_configs_values("scoped_style") end end |
#awesome_version ⇒ Object
53 54 55 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 53 def awesome_version ::Decidim::DecidimAwesome::VERSION end |
#awesome_voting_manifest_for(component) ⇒ Object
this will check if the current component has been configured to use a custom voting manifest
99 100 101 102 103 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 99 def awesome_voting_manifest_for(component) memoize("awesome_voting_manifest_for_#{component.id}") do DecidimAwesome.voting_registry.find(component.settings.try(:awesome_voting_manifest)) end end |
#javascript_config_vars ⇒ Object
28 29 30 31 32 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 28 def javascript_config_vars memoize("javascript_config_vars") do awesome_config.slice(:allow_images_in_proposals, :allow_images_in_editors, :allow_videos_in_editors, :auto_save_forms).to_json.html_safe end end |
#organization_awesome_config ⇒ Object
47 48 49 50 51 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 47 def organization_awesome_config memoize("organization_awesome_config") do awesome_config_instance.organization_config end end |
#show_public_intergram? ⇒ Boolean
34 35 36 37 38 39 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 34 def show_public_intergram? return false unless awesome_config[:intergram_for_public] return true unless awesome_config[:intergram_for_public_settings][:require_login] user_signed_in? end |
#unfiltered_awesome_config ⇒ Object
41 42 43 44 45 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 41 def unfiltered_awesome_config memoize("unfiltered_awesome_config") do awesome_config_instance.unfiltered_config end end |
#version_prefix ⇒ Object
113 114 115 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 113 def version_prefix "v#{Decidim.version[0..3]}" end |