Class: Spina::Admin::Conferences::ConferencesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spina/admin/conferences/conferences_controller.rb

Overview

Controller for Conference objects.

See Also:

Constant Summary collapse

PARTS_PARAMS =
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
  images_attributes: i[filename signed_blob_id image_id alt],
  content_attributes: [
    :name, :title,
    parts_attributes: [
      :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
      images_attributes: i[filename signed_blob_id image_id alt]
    ]
  ]
].freeze
CONTENT_PARAMS =
Spina.config.locales.inject({}) { |params, locale| params.merge("#{locale}_content_attributes": [*PARTS_PARAMS]) }
PARAMS =
:start_date, :finish_date, :name, **CONTENT_PARAMS,
events_attributes: i[id name start_datetime finish_datetime description location] ].freeze
PARTS =
%w[text submission_url submission_email_address submission_date submission_text gallery sponsors].freeze

Actions collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Creates a conference.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 55

def create # rubocop:disable Metrics/MethodLength
  @conference = Conference.new(conference_params)

  if @conference.save
    redirect_to admin_conferences_conferences_path, success: t('.saved')
  else
    respond_to do |format|
      format.html do
        add_breadcrumb t('.new')
        render :new
      end
      format.turbo_stream { render partial: 'errors', locals: { errors: @conference.errors } }
    end
  end
end

#destroyvoid

This method returns an undefined value.

Destroys a conference.



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 89

def destroy # rubocop:disable Metrics/MethodLength
  if @conference.destroy
    redirect_to admin_conferences_conferences_path, success: t('.destroyed')
  else
    respond_to do |format|
      format.html do
        add_breadcrumb @conference.name
        render :edit
      end
      format.turbo_stream { render partial: 'errors', locals: { errors: @conference.errors } }
    end
  end
end

#editvoid

This method returns an undefined value.

Renders a form for an existing conference.



49
50
51
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 49

def edit
  add_breadcrumb @conference.name
end

#indexvoid

This method returns an undefined value.

Renders a list of conferences.



35
36
37
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 35

def index
  @conferences = Conference.sorted.page(params[:page])
end

#newvoid

This method returns an undefined value.

Renders a form for a new conference.



41
42
43
44
45
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 41

def new
  @conference = Conference.new
  build_parts
  add_breadcrumb t('.new')
end

#updatevoid

This method returns an undefined value.

Updates a conference.



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/controllers/spina/admin/conferences/conferences_controller.rb', line 73

def update # rubocop:disable Metrics/MethodLength
  if @conference.update(conference_params)
    redirect_to admin_conferences_conferences_path, success: t('.saved')
  else
    respond_to do |format|
      format.html do
        add_breadcrumb @conference.name
        render :edit
      end
      format.turbo_stream { render partial: 'errors', locals: { errors: @conference.errors } }
    end
  end
end