<commit_before># frozen_string_literal: true

module Decidim
  module Elections
    module TrusteeZone
      # This controller is the abstract class from which all trustee_zone
      # controllers in their public engines should inherit from.

      class ApplicationController < ::Decidim::ApplicationController
        include Decidim::UserProfile

        helper_method :trustee

        before_action :ensure_configured_bulletin_board!

        private

        def ensure_configured_bulletin_board!
          return if Decidim::Elections.bulletin_board.configured?

          announcement_args = {
            callout_class: "alert",
            announcement: {
              title: "<strong>#{t("no_bulletin_board.title", scope: "decidim.elections.trustee_zone")}</strong>",
              body: t("no_bulletin_board.body", scope: "decidim.elections.trustee_zone")
            }
          }
          render html: cell("decidim/announcement", announcement_args), layout: true
        end

        def trustee
          @trustee ||= Decidim::Elections::Trustee.for(current_user)
        end

        def permission_scope
          :trustee_zone
        end

        def permission_class_chain
          [
            Decidim::Elections::Permissions,
            Decidim::Permissions
          ]
        end
      end
    end
  end
end
<commit_msg>Fix elections announcement (#7270)<commit_after># frozen_string_literal: true

module Decidim
  module Elections
    module TrusteeZone
      # This controller is the abstract class from which all trustee_zone
      # controllers in their public engines should inherit from.

      class ApplicationController < ::Decidim::ApplicationController
        include Decidim::UserProfile

        helper_method :trustee

        before_action :ensure_configured_bulletin_board!

        private

        def ensure_configured_bulletin_board!
          return if Decidim::Elections.bulletin_board.configured?

          announcement = {
            title: "<strong>#{t("no_bulletin_board.title", scope: "decidim.elections.trustee_zone")}</strong>",
            body: t("no_bulletin_board.body", scope: "decidim.elections.trustee_zone")
          }
          render html: cell("decidim/announcement", announcement, callout_class: "alert"), layout: true
        end

        def trustee
          @trustee ||= Decidim::Elections::Trustee.for(current_user)
        end

        def permission_scope
          :trustee_zone
        end

        def permission_class_chain
          [
            Decidim::Elections::Permissions,
            Decidim::Permissions
          ]
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07463249151903506, 'fraction_numerical': 0.0015077271013946476, 'mean_word_length': 2.380891719745223, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7664894', 'n_tokens_mistral': 740, 'n_tokens_neox': 709, 'n_words': 160}