Class: Decidim::Conferences::Admin::ConferenceSpeakersController
- Inherits:
-
ApplicationController
show all
- Includes:
- Concerns::ConferenceAdmin, Paginable
- Defined in:
- decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb
Overview
Controller that allows managing conference speakers.
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
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 27
def create
enforce_permission_to :create, :conference_speaker
@form = form(ConferenceSpeakerForm).from_params(params)
CreateConferenceSpeaker.call(@form, current_user, current_conference) do
on(:ok) do
flash[:notice] = I18n.t("conference_speakers.create.success", scope: "decidim.admin")
redirect_to conference_speakers_path(current_conference)
end
on(:invalid) do
flash[:alert] = I18n.t("conference_speakers.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 66
def destroy
enforce_permission_to :destroy, :conference_speaker, speaker: conference_speaker
DestroyConferenceSpeaker.call(conference_speaker, current_user) do
on(:ok) do
flash[:notice] = I18n.t("conference_speakers.destroy.success", scope: "decidim.admin")
redirect_to conference_speakers_path(current_conference)
end
end
end
|
#edit ⇒ Object
44
45
46
47
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 44
def edit
enforce_permission_to :update, :conference_speaker, speaker: conference_speaker
@form = form(ConferenceSpeakerForm).from_model(conference_speaker)
end
|
#index ⇒ Object
14
15
16
17
18
19
20
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 14
def index
enforce_permission_to :index, :conference_speaker
@query = params[:q]
@conference_speakers = paginate(Decidim::Conferences::Admin::ConferenceSpeakers.for(collection, @query))
end
|
#new ⇒ Object
22
23
24
25
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 22
def new
enforce_permission_to :create, :conference_speaker
@form = form(ConferenceSpeakerForm).instance
end
|
#update ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conference_speakers_controller.rb', line 49
def update
enforce_permission_to :update, :conference_speaker, speaker: conference_speaker
@form = form(ConferenceSpeakerForm).from_params(params)
UpdateConferenceSpeaker.call(@form, conference_speaker) do
on(:ok) do
flash[:notice] = I18n.t("conference_speakers.update.success", scope: "decidim.admin")
redirect_to conference_speakers_path(current_conference)
end
on(:invalid) do
flash.now[:alert] = I18n.t("conference_speakers.update.error", scope: "decidim.admin")
render :edit
end
end
end
|