Sha256: ddc67cc00f295d9cbf516814eb46169522da48b8a6c378c747d149f439dd1e2c

Contents?: true

Size: 1.88 KB

Versions: 64

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A form object used to create conference registration types from the admin dashboard.
      class RegistrationTypeForm < Form
        include TranslatableAttributes
        include Decidim::ApplicationHelper

        mimic :conference_registration_type

        translatable_attribute :title, String
        translatable_attribute :description, String

        attribute :weight, Integer
        attribute :price, Decimal
        attribute :conference_meeting_ids, Array[Integer]

        validates :title, :description, :weight, presence: true
        validates :weight, numericality: { greater_than_or_equal_to: 0 }
        validates :price, numericality: { greater_than_or_equal_to: 0 }, if: ->(form) { form.price.present? }

        def meetings
          meeting_components = current_participatory_space.components.where(manifest_name: "meetings")
          @meetings ||= Decidim::ConferenceMeeting.where(component: meeting_components)
                                                   &.order(title: :asc)
                                                   &.map do |meeting|
                                                     OpenStruct.new(
                                                       title: present(meeting).title,
                                                       value: meeting.id
                                                     )
                                                   end
        end

        def conference_meetings
          meeting_components = current_participatory_space.components.where(manifest_name: "meetings")
          return unless meeting_components || conference_meeting_ids.delete("").present?

          @conference_meetings ||= Decidim::ConferenceMeeting.where(component: meeting_components).where(id: conference_meeting_ids)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.4 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.27.9 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.29.0 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.3 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.27.8 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.29.0.rc4 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.29.0.rc3 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.29.0.rc2 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.29.0.rc1 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.2 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.27.7 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.1 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.27.6 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.26.10 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.26.9 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.0 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.27.5 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.0.rc5 app/forms/decidim/conferences/admin/registration_type_form.rb
decidim-conferences-0.28.0.rc4 app/forms/decidim/conferences/admin/registration_type_form.rb