-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathtemplate_customization_transfers_controller.rb
More file actions
33 lines (27 loc) · 1.19 KB
/
template_customization_transfers_controller.rb
File metadata and controls
33 lines (27 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
# frozen_string_literal: true
module OrgAdmin
# Controller that handles transferring parent template changes to a customized template
class TemplateCustomizationTransfersController < ApplicationController
include Versionable
after_action :verify_authorized
# POST /org_admin/templates/:id/transfer_customization
#
# The funder template's id is passed through here
def create
@template = Template.find(params[:template_id])
authorize @template, :transfer_customization?
if @template.upgrade_customization?
# If the customized template is not published it will not version, so publish it!
previously_published = @template.published?
@template.publish unless previously_published
@new_customization = @template.upgrade_customization!
# Reset the published flag if the customized template was not previously published
@template.update(published: false) unless previously_published
redirect_to org_admin_template_path(@new_customization)
else
flash[:alert] = _('That template is no longer customizable.')
redirect_back(fallback_location: org_admin_templates_path)
end
end
end
end