Sha256: 3aa8639e68e80b2f8bb495a586091684038838a63510fbae11252d485b3f6b52

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # This controller allows a participant to update the closing_report and the linked proposals of a closed meeting
    class MeetingClosesController < Decidim::Meetings::ApplicationController
      include Decidim::Proposals::Admin::Picker
      include FormFactory

      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 meeting_path(meeting)
          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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-meetings-0.24.3 app/controllers/decidim/meetings/meeting_closes_controller.rb
decidim-meetings-0.24.2 app/controllers/decidim/meetings/meeting_closes_controller.rb
decidim-meetings-0.24.1 app/controllers/decidim/meetings/meeting_closes_controller.rb
decidim-meetings-0.24.0 app/controllers/decidim/meetings/meeting_closes_controller.rb
decidim-meetings-0.24.0.rc2 app/controllers/decidim/meetings/meeting_closes_controller.rb
decidim-meetings-0.24.0.rc1 app/controllers/decidim/meetings/meeting_closes_controller.rb