Sha256: dbb12de5b9fb3fc37373a57396af7d62162094740852300695f9eba205eebf10

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders specific _partials_ for the `terms_and_conditions` StaticPage
  # the `model` is the partial to render
  # - :announcement, the TOS updated announcement when redirected to the TOS page.
  # - :sticky_form, the Accept updated TOS form in the TOS page.
  # - :refuse_btn_modal, the Modal with info when refusing the updated TOS.
  class TosPageCell < Decidim::ViewModel
    include Decidim::SanitizeHelper
    include Cell::ViewModel::Partial

    delegate :current_user, to: :controller, prefix: false

    def show
      return if model.nil?
      return unless current_user
      return if current_user.tos_accepted?
      render model
    end

    private

    def announcement_args
      args = {
        callout_class: "warning",
        announcement: {
          title: t("required_review.title", scope: "decidim.pages.terms_and_conditions"),
          body: t("required_review.body", scope: "decidim.pages.terms_and_conditions")
        }
      }
      args
    end

    def decidim
      Decidim::Core::Engine.routes.url_helpers
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.13.1 app/cells/decidim/tos_page_cell.rb
decidim-core-0.12.2 app/cells/decidim/tos_page_cell.rb
decidim-core-0.13.0 app/cells/decidim/tos_page_cell.rb
decidim-core-0.12.1 app/cells/decidim/tos_page_cell.rb
decidim-core-0.13.0.pre1 app/cells/decidim/tos_page_cell.rb
decidim-core-0.12.0 app/cells/decidim/tos_page_cell.rb
decidim-core-0.12.0.pre app/cells/decidim/tos_page_cell.rb