Sha256: 7ad4ef832421a518ad5fee6909b90ba29746ebbc0cde5d86ae795f7521c702b7

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require_dependency "decidim/admin/application_controller"

module Decidim
  module Meetings
    module Admin
      # Controller that allows inviting users to join a meeting.
      #
      class InvitesController < Admin::ApplicationController
        def new
          enforce_permission_to :invite_user, :meeting, meeting: meeting

          @form = form(MeetingRegistrationInviteForm).instance
        end

        def create
          enforce_permission_to :invite_user, :meeting, meeting: meeting

          @form = form(MeetingRegistrationInviteForm).from_params(params)

          InviteUserToJoinMeeting.call(@form, meeting, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("invites.create.success", scope: "decidim.meetings.admin")
              redirect_to edit_meeting_registrations_path(meeting)
            end

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

        private

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-meetings-0.13.1 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.12.2 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.13.0 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.12.1 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.13.0.pre1 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.12.0 app/controllers/decidim/meetings/admin/invites_controller.rb
decidim-meetings-0.12.0.pre app/controllers/decidim/meetings/admin/invites_controller.rb