Class: Decidim::Meetings::Admin::MeetingsController

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

Overview

This controller allows an admin to manage meetings from a Participatory Process

Instance Method Summary collapse

Methods inherited from ApplicationController

#meeting, #meetings

Methods inherited from Admin::Features::BaseController

#current_feature, #current_participatory_space, #parent_path

Methods inherited from Admin::ApplicationController

#current_ability_klass, #user_not_authorized_path

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 12

def create
  @form = form(MeetingForm).from_params(params, current_feature: current_feature)

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

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

#destroyObject



48
49
50
51
52
53
54
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 48

def destroy
  meeting.destroy!

  flash[:notice] = I18n.t("meetings.destroy.success", scope: "decidim.meetings.admin")

  redirect_to meetings_path
end

#editObject



28
29
30
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 28

def edit
  @form = form(MeetingForm).from_model(meeting)
end

#newObject



8
9
10
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 8

def new
  @form = form(MeetingForm).instance
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 32

def update
  @form = form(MeetingForm).from_params(params, current_feature: current_feature)

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

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