Class: Decidim::Conferences::Admin::ConferenceSpeakersController

Inherits:
ApplicationController show all
Includes:
Decidim::Conferences::Admin::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

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



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

#indexObject



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

#newObject



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

#updateObject



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