Sha256: 23d8401ad3b3d1cf47a909d5127a05bf4c23a8f6da818bf507bc7b477f0a8b48

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # Controller that allows managing meetings.
      #
      class MeetingCopiesController < Admin::ApplicationController
        helper_method :meeting, :blank_service

        def new
          @form = form(MeetingCopyForm).from_model(meeting)
        end

        def create
          @form = form(MeetingCopyForm).from_params(params, current_component: current_component)

          CopyMeeting.call(@form, meeting) do
            on(:ok) do
              flash[:notice] = I18n.t("meeting_copies.create.success", scope: "decidim.admin")
              redirect_to meetings_path
            end

            on(:invalid) do
              flash.now[:alert] = I18n.t("meeting_copies.create.error", scope: "decidim.admin")
              render :new
            end
          end
        end

        private

        def blank_service
          @blank_service ||= Admin::MeetingServiceForm.new
        end

        def meeting
          @meeting ||= Meeting.where(component: current_component).find(params[:meeting_id])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-meetings-0.11.2 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.11.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.11.0.pre1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb