Sha256: 8c9eec346199c6e67670de9d85d2428cb191164fb6bc91f7bb37c5ee89302f4f

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    # This cell renders the media link card for an instance of a RegistrationType
    class RegistrationTypeCell < Decidim::ViewModel
      include ActionView::Helpers::NumberHelper
      include Decidim::SanitizeHelper
      include Decidim::Conferences::Engine.routes.url_helpers
      include Decidim::LayoutHelper

      def show
        render
      end

      private

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

      def title
        decidim_sanitize translated_attribute model.title
      end

      def description
        decidim_sanitize_editor translated_attribute model.description
      end

      def price
        return I18n.t("free", scope: "decidim.conferences.conference.show") if model.price.blank?

        number_to_currency(model.price, locale: I18n.locale, unit: Decidim.currency_unit)
      end

      def allowed?
        options[:allowed]
      end

      def button_classes
        "button button--sc small"
      end

      def conference
        model.conference
      end

      def i18n_join_text
        return I18n.t("registration", scope: "decidim.conferences.conference.show") if conference.has_available_slots?

        I18n.t("no_slots_available", scope: "decidim.conferences.conference.show")
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-conferences-0.26.1 app/cells/decidim/conferences/registration_type_cell.rb
decidim-conferences-0.26.0 app/cells/decidim/conferences/registration_type_cell.rb
decidim-conferences-0.26.0.rc2 app/cells/decidim/conferences/registration_type_cell.rb
decidim-conferences-0.26.0.rc1 app/cells/decidim/conferences/registration_type_cell.rb