Class: Decidim::Admin::StaticPagesController
Overview
Controller that allows managing all pages at the admin panel.
Instance Method Summary
collapse
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 24
def create
enforce_permission_to :create, :static_page
@form = form(StaticPageForm).from_params(form_params)
CreateStaticPage.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("static_pages.create.success", scope: "decidim.admin")
redirect_to static_pages_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("static_pages.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 68
def destroy
enforce_permission_to :destroy, :static_page, static_page: page
DestroyStaticPage.call(page, current_user) do
on(:ok) do
flash[:notice] = I18n.t("static_pages.destroy.success", scope: "decidim.admin")
redirect_to static_pages_path
end
end
end
|
#edit ⇒ Object
41
42
43
44
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 41
def edit
enforce_permission_to :update, :static_page, static_page: page
@form = form(StaticPageForm).from_model(page)
end
|
#index ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 13
def index
enforce_permission_to :read, :static_page
@topics = Decidim::StaticPageTopic.where(organization: current_organization)
@orphan_pages = collection.where(topic: nil)
end
|
#new ⇒ Object
19
20
21
22
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 19
def new
enforce_permission_to :create, :static_page
@form = form(StaticPageForm).instance
end
|
#show ⇒ Object
64
65
66
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 64
def show
enforce_permission_to :read, :static_page
end
|
#update ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/decidim/admin/static_pages_controller.rb', line 46
def update
@page = collection.find(params[:id])
enforce_permission_to :update, :static_page, static_page: page
@form = form(StaticPageForm).from_params(form_params)
UpdateStaticPage.call(page, @form) do
on(:ok) do
flash[:notice] = I18n.t("static_pages.update.success", scope: "decidim.admin")
redirect_to static_pages_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("static_pages.update.error", scope: "decidim.admin")
render :edit
end
end
end
|