Class: Decidim::Meetings::Admin::AgendaController

Inherits:
ApplicationController show all
Defined in:
decidim-meetings/app/controllers/decidim/meetings/admin/agenda_controller.rb

Overview

Controller that allows managing the agendas for the given meeting

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, #set_component_breadcrumb_item, #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 Headers::HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



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

def create
  enforce_permission_to(:create, :agenda, meeting:)

  @form = form(MeetingAgendaForm).from_params(params, meeting:)

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

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

#editObject



35
36
37
38
39
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/agenda_controller.rb', line 35

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

  @form = form(MeetingAgendaForm).from_model(agenda)
end

#newObject



11
12
13
14
15
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/agenda_controller.rb', line 11

def new
  enforce_permission_to(:create, :agenda, meeting:)

  @form = form(MeetingAgendaForm).instance
end

#updateObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/agenda_controller.rb', line 41

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

  @form = form(MeetingAgendaForm).from_params(params, meeting:)

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

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