Class: Decidim::Admin::StaticPageTopicsController
Instance Method Summary
collapse
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/decidim/admin/static_page_topics_controller.rb', line 14
def create
enforce_permission_to :create, :static_page_topic
@form = form(StaticPageTopicForm).from_params(params["static_page_topic"])
CreateStaticPageTopic.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("static_page_topics.create.success", scope: "decidim.admin")
redirect_to static_pages_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("static_page_topics.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/decidim/admin/static_page_topics_controller.rb', line 53
def destroy
enforce_permission_to :destroy, :static_page_topic, static_page_topic: topic
DestroyStaticPage.call(topic, current_user) do
on(:ok) do
flash[:notice] = I18n.t("static_page_topics.destroy.success", scope: "decidim.admin")
redirect_to static_pages_path
end
end
end
|
#edit ⇒ Object
31
32
33
34
|
# File 'app/controllers/decidim/admin/static_page_topics_controller.rb', line 31
def edit
enforce_permission_to :update, :static_page_topic, static_page_topic: topic
@form = form(StaticPageTopicForm).from_model(topic)
end
|
#new ⇒ Object
9
10
11
12
|
# File 'app/controllers/decidim/admin/static_page_topics_controller.rb', line 9
def new
enforce_permission_to :create, :static_page_topic
@form = form(StaticPageTopicForm).instance
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/decidim/admin/static_page_topics_controller.rb', line 36
def update
enforce_permission_to :update, :static_page_topic, static_page_topic: topic
@form = form(StaticPageTopicForm).from_params(params["static_page_topic"])
UpdateStaticPageTopic.call(topic, @form) do
on(:ok) do
flash[:notice] = I18n.t("static_page_topics.update.success", scope: "decidim.admin")
redirect_to static_pages_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("static_page_topics.update.error", scope: "decidim.admin")
render :edit
end
end
end
|