Sha256: c73ae465186448e1df763342081f977fe3502f3dd8301acd6a05fe2faf3f83a2

Contents?: true

Size: 1.48 KB

Versions: 34

Compression:

Stored size: 1.48 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
        helper_method :invites

        def index
          enforce_permission_to :read_invites, :meeting, meeting: meeting

          @query = params[:q]
          @status = params[:status]

          @form = form(MeetingRegistrationInviteForm).instance
        end

        def create
          enforce_permission_to :invite_attendee, :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 meeting_registrations_invites_path(meeting)
            end

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

        private

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

        def invites
          @invites ||= Decidim::Meetings::Admin::Invites.for(meeting.invites, @query, @status).page(params[:page]).per(15)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

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