Sha256: 6f87a6087b36b2f72653fbba911a3e324e70d9a22025c26fab85d1d4501c3d66

Contents?: true

Size: 1.25 KB

Versions: 59

Compression:

Stored size: 1.25 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
          enforce_permission_to :copy, :meeting, meeting: meeting

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

        def create
          enforce_permission_to :copy, :meeting, meeting: meeting

          @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

59 entries across 59 versions & 1 rubygems

Version Path
decidim-meetings-0.24.2 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.5 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.24.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.24.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.24.0.rc2 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.4 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.24.0.rc1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.3 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.2 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.1.rc1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.23.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.22.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.21.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.20.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.20.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.19.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.18.1 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.19.0 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb
decidim-meetings-0.17.2 app/controllers/decidim/meetings/admin/meeting_copies_controller.rb