Class: Decidim::Meetings::RegistrationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/meetings/registrations_controller.rb

Overview

Exposes the registration resource so users can join and leave meetings.

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 7

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

#destroyObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/decidim/meetings/registrations_controller.rb', line 23

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