Class: Decidim::Proposals::Admin::ProposalStatesController
Constant Summary
Decidim::Paginable::OPTIONS
Instance Method Summary
collapse
#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #set_component_breadcrumb_item, #skip_manage_component_permission
register_permissions
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
#disable_http_caching
#default_locale?
#snippets
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 19
def create
enforce_permission_to :create, :proposal_state
@form = form(ProposalStateForm).from_params(params)
CreateProposalState.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("proposal_states.create.success", scope: "decidim.proposals.admin")
redirect_to proposal_states_path
end
on(:invalid) do
flash.keep[:alert] = I18n.t("proposal_states.create.error", scope: "decidim.proposals.admin")
render action: :new
end
end
end
|
#destroy ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 62
def destroy
enforce_permission_to(:destroy, :proposal_state, proposal_state:)
DestroyProposalState.call(proposal_state, current_user) do
on(:ok) do
flash[:notice] = I18n.t("proposal_states.destroy.success", scope: "decidim.proposals.admin")
redirect_to proposal_states_path
end
end
end
|
#edit ⇒ Object
38
39
40
41
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 38
def edit
enforce_permission_to(:update, :proposal_state, proposal_state:)
@form = form(Decidim::Proposals::Admin::ProposalStateForm).from_model(proposal_state)
end
|
#index ⇒ Object
10
11
12
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 10
def index
enforce_permission_to :read, :proposal_state
end
|
#new ⇒ Object
14
15
16
17
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 14
def new
enforce_permission_to :create, :proposal_state
@form = form(Decidim::Proposals::Admin::ProposalStateForm).instance
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_controller.rb', line 43
def update
enforce_permission_to(:update, :proposal_state, proposal_state:)
@form = form(ProposalStateForm).from_params(params)
UpdateProposalState.call(@form, proposal_state) do
on(:ok) do
flash[:notice] = I18n.t("proposal_states.update.success", scope: "decidim.proposals.admin")
redirect_to proposal_states_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("proposal_states.update.error", scope: "decidim.proposals.admin")
render action: :edit
end
end
end
|