Class: Decidim::Meetings::Admin::RegistrationsController

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

Overview

This controller allows an admin to manage meeting registrations from a Participatory Process

Instance Method Summary collapse

Methods inherited from ApplicationController

#maps_enabled?, #meetings

Instance Method Details

#editObject



8
9
10
11
12
13
# File 'app/controllers/decidim/meetings/admin/registrations_controller.rb', line 8

def edit
  enforce_permission_to(:update, :meeting, meeting:)

  @form = MeetingRegistrationsForm.from_model(meeting)
  @validation_form = ValidateRegistrationCodeForm.new
end

#exportObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/decidim/meetings/admin/registrations_controller.rb', line 34

def export
  enforce_permission_to(:export_registrations, :meeting, meeting:)

  ExportMeetingRegistrations.call(meeting, params[:format], current_user) do
    on(:ok) do |export_data|
      send_data export_data.read, type: "text/#{export_data.extension}", filename: export_data.filename("registrations")
    end
  end
end

#updateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/meetings/admin/registrations_controller.rb', line 15

def update
  enforce_permission_to(:update, :meeting, meeting:)

  @form = MeetingRegistrationsForm.from_params(params).with_context(current_organization: meeting.organization, meeting:)
  @validation_form = ValidateRegistrationCodeForm.new

  UpdateRegistrations.call(@form, meeting) do
    on(:ok) do
      flash[:notice] = I18n.t("registrations.update.success", scope: "decidim.meetings.admin")
      redirect_to meetings_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("registrations.update.invalid", scope: "decidim.meetings.admin")
      render action: "edit"
    end
  end
end

#validate_registration_codeObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/decidim/meetings/admin/registrations_controller.rb', line 44

def validate_registration_code
  enforce_permission_to(:update, :meeting, meeting:)

  @form = MeetingRegistrationsForm.from_model(meeting)
  @validation_form = ValidateRegistrationCodeForm.from_params(params).with_context(current_organization: meeting.organization, meeting:)

  ValidateRegistrationCode.call(@validation_form, meeting) do
    on(:ok) do
      flash[:notice] = I18n.t("registrations.validate_registration_code.success", scope: "decidim.meetings.admin")
      render action: "edit"
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("registrations.validate_registration_code.invalid", scope: "decidim.meetings.admin")
      render action: "edit"
    end
  end
end