Class: Decidim::Conferences::Admin::MediaLinksController
Overview
Controller that allows managing conference media links.
Constant Summary
Constants included
from Paginable
Paginable::OPTIONS
Instance Method Summary
collapse
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
#disable_http_caching
#snippets
register_permissions
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 22
def create
enforce_permission_to :create, :media_link
@form = form(Decidim::Conferences::Admin::MediaLinkForm).from_params(params)
CreateMediaLink.call(@form, current_user, current_conference) do
on(:ok) do
flash[:notice] = I18n.t("media_links.create.success", scope: "decidim.admin")
redirect_to conference_media_links_path(current_conference)
end
on(:invalid) do
flash[:alert] = I18n.t("media_links.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 63
def destroy
@media_link = collection.find(params[:id])
enforce_permission_to :destroy, :media_link, speaker: @media_link
DestroyMediaLink.call(@media_link, current_user) do
on(:ok) do
flash[:notice] = I18n.t("media_links.destroy.success", scope: "decidim.admin")
redirect_to conference_media_links_path(current_conference)
end
end
end
|
#edit ⇒ Object
39
40
41
42
43
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 39
def edit
@media_link = collection.find(params[:id])
enforce_permission_to :update, :media_link, speaker: @media_link
@form = form(MediaLinkForm).from_model(@media_link)
end
|
#index ⇒ Object
11
12
13
14
15
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 11
def index
enforce_permission_to :index, :media_link
@media_links = paginate(collection)
end
|
#new ⇒ Object
17
18
19
20
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 17
def new
enforce_permission_to :create, :media_link
@form = form(Decidim::Conferences::Admin::MediaLinkForm).instance
end
|
#update ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/media_links_controller.rb', line 45
def update
@media_link = collection.find(params[:id])
enforce_permission_to :update, :media_link, speaker: @media_link
@form = form(MediaLinkForm).from_params(params)
UpdateMediaLink.call(@form, @media_link) do
on(:ok) do
flash[:notice] = I18n.t("media_links.update.success", scope: "decidim.admin")
redirect_to conference_media_links_path(current_conference)
end
on(:invalid) do
flash.now[:alert] = I18n.t("media_links.update.error", scope: "decidim.admin")
render :edit
end
end
end
|