Class: Decidim::Debates::DebatesController
Overview
Exposes the debate resource so users can view them
Constant Summary
Constants included
from Paginable
Paginable::OPTIONS
Instance Method Summary
collapse
#current_component, #current_manifest, #current_participatory_space, #permission_class_chain, #permission_scope, #redirect_unless_feature_private, #set_component_breadcrumb_item
register_permissions
#store_share_token
#check_user_block_status, #check_user_not_blocked
#snippets
#disable_http_caching
#skip_store_location?, #store_current_location
#default_locale?
enhance_controller, extended, included
Instance Method Details
#close ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 70
def close
enforce_permission_to(:close, :debate, debate:)
@form = form(CloseDebateForm).from_params(params)
CloseDebate.call(@form) do
on(:ok) do |debate|
flash[:notice] = I18n.t("debates.close.success", scope: "decidim.debates")
redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path
end
on(:invalid) do
flash[:alert] = I18n.t("debates.close.invalid", scope: "decidim.debates")
redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path
end
end
end
|
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 24
def create
enforce_permission_to :create, :debate
@form = form(DebateForm).from_params(params)
CreateDebate.call(@form) do
on(:ok) do |debate|
flash[:notice] = I18n.t("debates.create.success", scope: "decidim.debates")
redirect_to Decidim::ResourceLocatorPresenter.new(debate).path
end
on(:invalid) do
flash.now[:alert] = I18n.t("debates.create.invalid", scope: "decidim.debates")
render action: "new"
end
end
end
|
#edit ⇒ Object
46
47
48
49
50
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 46
def edit
enforce_permission_to(:edit, :debate, debate:)
@form = form(DebateForm).from_model(debate)
end
|
#new ⇒ Object
18
19
20
21
22
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 18
def new
enforce_permission_to :create, :debate
@form = form(DebateForm).instance
end
|
#show ⇒ Object
42
43
44
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 42
def show
raise ActionController::RoutingError, "Not Found" if debate.blank?
end
|
#update ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'decidim-debates/app/controllers/decidim/debates/debates_controller.rb', line 52
def update
enforce_permission_to(:edit, :debate, debate:)
@form = form(DebateForm).from_params(params)
UpdateDebate.call(@form, debate) do
on(:ok) do |debate|
flash[:notice] = I18n.t("debates.update.success", scope: "decidim.debates")
redirect_to Decidim::ResourceLocatorPresenter.new(debate).path
end
on(:invalid) do
flash.now[:alert] = I18n.t("debates.update.invalid", scope: "decidim.debates")
render :edit
end
end
end
|