Sha256: 7eabcccd4a648728de0814a25d96a95a17c9e772d6b6f3ebd38dedbafe21d1e8

Contents?: true

Size: 1.25 KB

Versions: 66

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # This class holds a Form to close a meeting from Decidim's admin panel.
      class CloseMeetingForm < Decidim::Form
        include TranslatableAttributes

        translatable_attribute :closing_report, String
        attribute :attendees_count, Integer, default: 0
        attribute :contributions_count, Integer, default: 0
        attribute :attending_organizations, String
        attribute :proposal_ids, Array[Integer]
        attribute :proposals
        attribute :closed_at, DateTime, default: ->(_form, _attribute) { Time.current }

        validates :closing_report, translatable_presence: true
        validates :attendees_count, presence: true, numericality: { greater_than_or_equal_to: 0 }
        validates :contributions_count, numericality: true, allow_blank: true
        validates :attending_organizations, presence: true

        # Private: Gets the proposals from the meeting and injects them to the form.
        #
        # Returns nothing.
        def map_model(model)
          self.proposal_ids = model.linked_resources(:proposals, "proposals_from_meeting").pluck(:id)
          self.proposals = model.sibling_scope(:proposals)
        end
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
decidim-meetings-0.13.1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.12.2 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.13.0 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.12.1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.13.0.pre1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.12.0 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.11.2 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.12.0.pre app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.11.1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.11.0.pre1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.10.1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.10.0 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.9.3 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.9.2 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.9.1 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.9.0 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.8.4 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.8.3 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.8.2 app/forms/decidim/meetings/admin/close_meeting_form.rb
decidim-meetings-0.8.1 app/forms/decidim/meetings/admin/close_meeting_form.rb