-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtime_period_editions_controller.rb
More file actions
51 lines (41 loc) · 1.19 KB
/
time_period_editions_controller.rb
File metadata and controls
51 lines (41 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Block
class TimePeriodEditionsController < ApplicationController
before_action :set_edition, only: %i[show edit update]
before_action :set_organisations, only: %i[new create]
def new
@edition = Block::TimePeriodEdition.new
@edition.build_document(block_type: "time_period")
end
def create
@edition = Block::TimePeriodEdition.new(edition_params)
@edition.build_document(block_type: "time_period") unless @edition.document
if @edition.save
redirect_to edit_block_document_time_period_date_range_path(
@edition.document,
@edition,
)
else
render :new, status: :unprocessable_entity
end
end
def show; end
def edit; end
def update; end
private
def set_edition
@edition = Block::TimePeriodEdition.find(params[:id])
end
def set_organisations
@organisations = [{ text: "", value: "" }] +
Organisation.all.map { |org| { text: org.name, value: org.id } }
end
def edition_params
params.require(:edition).permit(
:title,
:description,
:instructions_to_publishers,
:lead_organisation_id,
)
end
end
end