Class: Decidim::Conferences::Admin::ConferencesController

Inherits:
ApplicationController show all
Includes:
Filterable
Defined in:
decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb

Overview

Controller that allows managing conferences.

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 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

#copyObject


66
67
68
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 66

def copy
  enforce_permission_to :create, :conference
end

#createObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 23

def create
  enforce_permission_to :create, :conference
  @form = form(ConferenceForm).from_params(params)

  CreateConference.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("conferences.create.success", scope: "decidim.admin")
      redirect_to conferences_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("conferences.create.error", scope: "decidim.admin")
      render :new
    end
  end
end

#editObject


40
41
42
43
44
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 40

def edit
  enforce_permission_to :update, :conference, conference: current_conference
  @form = form(ConferenceForm).from_model(current_conference)
  render layout: "decidim/admin/conference"
end

#indexObject


13
14
15
16
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 13

def index
  enforce_permission_to :read, :conference_list
  @conferences = filtered_collection
end

#newObject


18
19
20
21
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 18

def new
  enforce_permission_to :create, :conference
  @form = form(ConferenceForm).instance
end

#updateObject


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/conferences_controller.rb', line 46

def update
  enforce_permission_to :update, :conference, conference: current_conference
  @form = form(ConferenceForm).from_params(
    conference_params,
    conference_id: current_conference.id
  )

  UpdateConference.call(current_conference, @form) do
    on(:ok) do |conference|
      flash[:notice] = I18n.t("conferences.update.success", scope: "decidim.admin")
      redirect_to edit_conference_path(conference)
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("conferences.update.error", scope: "decidim.admin")
      render :edit, layout: "decidim/admin/conference"
    end
  end
end