Sha256: 8a1106dfecf4772776cb854c867fb92e9eb1b960c1309681485c4d4d3bc01cf3

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

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

        helper_method :conference

        add_breadcrumb_item_from_menu :conferences_admin_registrations_menu

        alias conference current_participatory_space

        def index
          enforce_permission_to(:read_invites, :conference, conference: current_participatory_space)

          @conference_invites = filtered_collection
        end

        def new
          enforce_permission_to(:invite_attendee, :conference, conference: current_participatory_space)

          @form = form(ConferenceRegistrationInviteForm).instance
        end

        def create
          enforce_permission_to(:invite_attendee, :conference, conference: current_participatory_space)

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

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

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

        private

        def collection
          current_conference.conference_invites
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/controllers/decidim/conferences/admin/conference_invites_controller.rb
decidim-conferences-0.29.0 app/controllers/decidim/conferences/admin/conference_invites_controller.rb
decidim-conferences-0.29.0.rc4 app/controllers/decidim/conferences/admin/conference_invites_controller.rb
decidim-conferences-0.29.0.rc3 app/controllers/decidim/conferences/admin/conference_invites_controller.rb
decidim-conferences-0.29.0.rc2 app/controllers/decidim/conferences/admin/conference_invites_controller.rb
decidim-conferences-0.29.0.rc1 app/controllers/decidim/conferences/admin/conference_invites_controller.rb