Sha256: 09745a3327f258d6cdb2119c5bc11c416f2d0e30c4b4578633c6e8283aba7dae

Contents?: true

Size: 1.73 KB

Versions: 29

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

require_dependency "decidim/admin/application_controller"

module Decidim
  module Conferences
    module Admin
      # Controller that allows inviting users to join a conference.
      #
      class ConferenceInvitesController < Decidim::Conferences::Admin::ApplicationController
        include Concerns::ConferenceAdmin

        helper_method :conference

        def index
          enforce_permission_to :read_invites, :conference, conference: conference

          @query = params[:q]
          @status = params[:status]
          @conference_invites = Decidim::Conferences::Admin::ConferenceInvites.for(conference.conference_invites, @query, @status).page(params[:page]).per(15)
        end

        def new
          enforce_permission_to :invite_attendee, :conference, conference: conference

          @form = form(ConferenceRegistrationInviteForm).instance
        end

        def create
          enforce_permission_to :invite_attendee, :conference, conference: conference

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

          InviteUserToJoinConference.call(@form, conference, current_user) do
            on(:ok) do
              flash[:notice] = I18n.t("conference_invites.create.success", scope: "decidim.conferences.admin")
              redirect_to conference_conference_invites_path(conference)
            end

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

        private

        def conference
          @conference ||= Decidim::Conference.find_by(slug: params[:conference_slug])
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

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