Sha256: 60fece5b89414bf44f340e5668de9ca7b7d366e2d8a68751d222a631caeb8fae

Contents?: true

Size: 1.31 KB

Versions: 34

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # Exposes the registration resource so users can join and leave meetings.
    class RegistrationsController < Decidim::Meetings::ApplicationController
      def create
        authorize! :join, meeting

        JoinMeeting.call(meeting, current_user) do
          on(:ok) do
            flash[:notice] = I18n.t("registrations.create.success", scope: "decidim.meetings")
            redirect_to meeting_path(meeting)
          end

          on(:invalid) do
            flash.now[:alert] = I18n.t("registrations.create.invalid", scope: "decidim.meetings")
            redirect_to meeting_path(meeting)
          end
        end
      end

      def destroy
        authorize! :leave, meeting

        LeaveMeeting.call(meeting, current_user) do
          on(:ok) do
            flash[:notice] = I18n.t("registrations.destroy.success", scope: "decidim.meetings")
            redirect_to meeting_path(meeting)
          end

          on(:invalid) do
            flash.now[:alert] = I18n.t("registrations.destroy.invalid", scope: "decidim.meetings")
            redirect_to meeting_path(meeting)
          end
        end
      end

      private

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

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
decidim-meetings-0.10.1 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.10.0 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.9.3 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.9.2 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.9.1 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.9.0 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.8.4 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.8.3 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.8.2 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.8.1 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.8.0 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.7.4 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.7.3 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.7.2 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.7.1 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.7.0 app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.6.8 app/controllers/decidim/meetings/registrations_controller.rb
decidim-0.6.8 decidim-meetings/app/controllers/decidim/meetings/registrations_controller.rb
decidim-meetings-0.6.7 app/controllers/decidim/meetings/registrations_controller.rb
decidim-0.6.7 decidim-meetings/app/controllers/decidim/meetings/registrations_controller.rb