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

Inherits:
ApplicationController show all
Defined in:
decidim-meetings/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

Methods inherited from Admin::Components::BaseController

#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #skip_manage_component_permission

Methods included from RegistersPermissions

register_permissions

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#editObject


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

def edit
  enforce_permission_to :update, :meeting, meeting: meeting

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

#exportObject


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

def export
  enforce_permission_to :export_registrations, :meeting, 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 'decidim-meetings/app/controllers/decidim/meetings/admin/registrations_controller.rb', line 15

def update
  enforce_permission_to :update, :meeting, meeting: meeting

  @form = MeetingRegistrationsForm.from_params(params).with_context(current_organization: meeting.organization, meeting: 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 'decidim-meetings/app/controllers/decidim/meetings/admin/registrations_controller.rb', line 44

def validate_registration_code
  enforce_permission_to :update, :meeting, meeting: meeting

  @form = MeetingRegistrationsForm.from_model(meeting)
  @validation_form = ValidateRegistrationCodeForm.from_params(params).with_context(current_organization: meeting.organization, meeting: 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