Sha256: 9da9935c65c24e77e6b7ace90faa5fdb4f4d75033bc6a41f65cca879a6872809

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # This controller allows an admin to manage meetings from a Participatory Process
      class MeetingClosesController < Admin::ApplicationController
        include Decidim::Proposals::Admin::Picker

        helper_method :meeting

        def edit
          enforce_permission_to :close, :meeting, meeting: meeting

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

        def update
          enforce_permission_to :close, :meeting, meeting: meeting

          @form = form(CloseMeetingForm).from_params(params.merge(proposals: meeting.sibling_scope(:proposals)))

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

            on(:invalid) do
              flash.now[:alert] = I18n.t("meetings.close.invalid", scope: "decidim.meetings.admin")
              render action: "edit"
            end
          end
        end

        private

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-meetings-0.23.6 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.5 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.4 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.3 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.2 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.1 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.1.rc1 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.23.0 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb
decidim-meetings-0.22.0 app/controllers/decidim/meetings/admin/meeting_closes_controller.rb