-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathunarchive_controller.rb
More file actions
33 lines (25 loc) · 1.21 KB
/
unarchive_controller.rb
File metadata and controls
33 lines (25 loc) · 1.21 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
module Forms
class UnarchiveController < FormsController
def new
authorize current_form, :can_make_form_live?
@make_live_input = MakeLiveInput.new(form: current_form)
render "unarchive_form", locals: { current_form: }
end
def create
authorize current_form, :can_make_form_live?
@make_live_input = MakeLiveInput.new(**unarchive_form_params)
return render "unarchive_form", status: :unprocessable_content, locals: { current_form: } unless @make_live_input.valid?
return redirect_to archived_form_path(current_form.id) unless @make_live_input.confirmed?
@make_form_live_service = MakeFormLiveService.call(current_form:, current_user:)
@make_form_live_service.make_live
if current_form.state_previously_changed?
OrgAdminAlertsService.new(form: current_form, current_user:).form_made_live
end
render "forms/make_live/confirmation", locals: { current_form:, confirmation_page_title: @make_form_live_service.page_title, confirmation_page_body: @make_form_live_service.confirmation_page_body }
end
private
def unarchive_form_params
params.require(:forms_make_live_input).permit(:confirm).merge(form: current_form)
end
end
end