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

#maps_enabled?, #meeting, #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

#createObject


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/meetings_controller.rb', line 16

def create
  enforce_permission_to :create, :meeting

  @form = meeting_form.from_params(params, current_component: current_component)

  Decidim::Meetings::Admin::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


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 58

def destroy
  enforce_permission_to :destroy, :meeting, meeting: meeting

  Decidim::Meetings::Admin::DestroyMeeting.call(meeting, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("meetings.destroy.success", scope: "decidim.meetings.admin")
      redirect_to meetings_path
    end

    on(:invalid) do |proposals_count|
      flash.now[:alert] = I18n.t(
        "meetings.destroy.invalid.proposals_count",
        count: proposals_count,
        scope: "decidim.meetings.admin"
      )

      render action: "index"
    end
  end
end

#editObject


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

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

  @form = meeting_form.from_model(meeting)
end

#newObject


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

def new
  enforce_permission_to :create, :meeting

  @form = meeting_form.instance
end

#publishObject


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 79

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

  Decidim::Meetings::Admin::PublishMeeting.call(meeting, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("meetings.publish.success", scope: "decidim.meetings.admin")
      redirect_to meetings_path
    end

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

#unpublishObject


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb', line 95

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

  Decidim::Meetings::Admin::UnpublishMeeting.call(meeting, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("meetings.unpublish.success", scope: "decidim.meetings.admin")
      redirect_to meetings_path
    end

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

#updateObject


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

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

  @form = meeting_form.from_params(params, current_component: current_component)

  Decidim::Meetings::Admin::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