Sha256: 0a85d71f2d412d72d16a1be51f2360b3455f8e9eb7537c7581c84536679abe3a

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
module Decidim
  module Meetings
    module Admin
      # This command is executed when the user creates a Meeting from the admin
      # panel.
      class CreateMeeting < Rectify::Command
        def initialize(form)
          @form = form
        end

        # Creates the meeting if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if @form.invalid?

          create_meeting!
          broadcast(:ok, @meeting)
        end

        private

        def create_meeting!
          @meeting = Meeting.create!(
            scope: @form.scope,
            category: @form.category,
            title: @form.title,
            description: @form.description,
            end_time: @form.end_time,
            start_time: @form.start_time,
            address: @form.address,
            latitude: @form.latitude,
            longitude: @form.longitude,
            location: @form.location,
            location_hints: @form.location_hints,
            feature: @form.current_feature
          )
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
decidim-meetings-0.1.0 app/commands/decidim/meetings/admin/create_meeting.rb
decidim-0.1.0 decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb
decidim-meetings-0.0.8.1 app/commands/decidim/meetings/admin/create_meeting.rb
decidim-0.0.8.1 decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb
decidim-meetings-0.0.7 app/commands/decidim/meetings/admin/create_meeting.rb
decidim-0.0.7 decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb
decidim-meetings-0.0.6 app/commands/decidim/meetings/admin/create_meeting.rb
decidim-0.0.6 decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb