Skip to content

Commit 9ead17b

Browse files
authored
Merge pull request #3301 from DMPRoadmap/fix-template-visibility
Fix template visibility for newly created plans
2 parents a5b76ba + eba5520 commit 9ead17b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/controllers/org_admin/templates_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module OrgAdmin
44
# Controller that handles templates
5+
# rubocop:disable Metrics/ClassLength
56
class TemplatesController < ApplicationController
67
include Paginable
78
include Versionable
@@ -157,6 +158,10 @@ def edit
157158
def new
158159
authorize Template
159160
@template = current_org.templates.new
161+
# If the Org is a funder set the visibility to Public otherwise set to Organizational
162+
# for Orgs that are both, the admin will see controls on the page to let them choose.
163+
# The default is already 'organisationally_visible' so change it if this is a funder
164+
@template.visibility = Template.visibilities[:publicly_visible] if current_org.funder?
160165
end
161166

162167
# POST /org_admin/templates
@@ -410,4 +415,5 @@ def get_referrer(template, referrer)
410415
end
411416
end
412417
end
418+
# rubocop:enable Metrics/ClassLength
413419
end

app/views/org_admin/templates/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<% else %>
3030
<%
3131
visibility = f.object.visibility
32-
visibility = f.object.funder? ? 'publicly_visible' : 'organisationally_visible' if visibility.nil?
32+
visibility = f.object.org.funder? ? 'publicly_visible' : 'organisationally_visible' if visibility.nil?
3333
%>
3434
<%= f.hidden_field :visibility, value: visibility %>
3535
<% end %>

0 commit comments

Comments
 (0)