Class: Decidim::Votings::Admin::MonitoringCommitteeMembersController

Inherits:
ApplicationController show all
Includes:
VotingAdmin
Defined in:
decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb

Overview

This controller allows to create or delete a monitoring committee member.

Instance Method Summary collapse

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 RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb', line 21

def create
  enforce_permission_to :create, :monitoring_committee_member, voting: current_voting
  @form = form(MonitoringCommitteeMemberForm).from_params(params, voting: current_voting)

  CreateMonitoringCommitteeMember.call(@form, current_user, current_voting) do
    on(:ok) do
      flash[:notice] = I18n.t("monitoring_committee_members.create.success", scope: "decidim.votings.admin")
      redirect_to voting_monitoring_committee_members_path(current_voting)
    end

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

#destroyObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb', line 38

def destroy
  enforce_permission_to :delete, :monitoring_committee_member, voting: current_voting, monitoring_committee_member: monitoring_committee_member

  DestroyMonitoringCommitteeMember.call(monitoring_committee_member, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("monitoring_committee_members.destroy.success", scope: "decidim.votings.admin")
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("monitoring_committee_members.destroy.invalid", scope: "decidim.votings.admin")
    end
  end

  redirect_to voting_monitoring_committee_members_path(current_voting)
end

#indexObject


12
13
14
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb', line 12

def index
  enforce_permission_to :read, :monitoring_committee_members, voting: current_voting
end

#newObject


16
17
18
19
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_members_controller.rb', line 16

def new
  enforce_permission_to :create, :monitoring_committee_member, voting: current_voting
  @form = form(MonitoringCommitteeMemberForm).instance
end