Class: Decidim::Conferences::Admin::DiplomasController

Inherits:
ApplicationController show all
Includes:
Concerns::ConferenceAdmin
Defined in:
decidim-conferences/app/controllers/decidim/conferences/admin/diplomas_controller.rb

Overview

This controller allows an admin to manage Conference Diploma configuration

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

#editObject


10
11
12
13
14
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/diplomas_controller.rb', line 10

def edit
  enforce_permission_to :update, :conference, conference: current_conference

  @form = form(DiplomaForm).from_model(current_conference)
end

#send_diplomasObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/diplomas_controller.rb', line 34

def send_diplomas
  enforce_permission_to :send_diplomas, :conference, conference: current_conference

  SendConferenceDiplomas.call(current_conference, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("send_diploma.success", scope: "decidim.conferences.admin")
      redirect_to edit_conference_diploma_path(current_conference)
    end

    on(:invalid) do
      flash[:alert] = I18n.t("send_diploma.error", scope: "decidim.conferences.admin")
      redirect_to edit_conference_diploma_path(current_conference)
    end
  end
end

#updateObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-conferences/app/controllers/decidim/conferences/admin/diplomas_controller.rb', line 16

def update
  enforce_permission_to :update, :conference, conference: current_conference

  @form = form(DiplomaForm).from_params(diploma_params).with_context(conference: current_conference)

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

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