diff --git a/app/controllers/org_admin/templates_controller.rb b/app/controllers/org_admin/templates_controller.rb index 8cc5c73..5229337 100644 --- a/app/controllers/org_admin/templates_controller.rb +++ b/app/controllers/org_admin/templates_controller.rb @@ -501,18 +501,13 @@ scopes = calculate_table_scopes(templates, customizations) - # We scope based on the customizations if the user is NOT a super admin + # We scope based on the customizations if params[:scope].present? && params[:scope] != 'all' - if current_user.can_super_admin? - templates = templates.where(published: true) if params[:scope] == 'published' - templates = templates.where(published: false) if params[:scope] == 'unpublished' - else - scoped = templates.select do |t| - c = customizations[t.dmptemplate_id] - (params[:scope] == 'unpublished' && (!c.present? || !c.published?)) || (params[:scope] == 'published' && c.present? && c.published?) - end - templates = Template.where(id: scoped.collect(&:id)) + scoped = templates.select do |t| + c = customizations[t.dmptemplate_id] + (params[:scope] == 'unpublished' && (!c.present? || !c.published?)) || (params[:scope] == 'published' && c.present? && c.published?) end + templates = Template.where(id: scoped.collect(&:id)) end else @@ -541,7 +536,7 @@ scopes = { all: templates.length, published: 0, unpublished: 0, dmptemplate_ids: templates.collect(&:dmptemplate_id).uniq } templates.each do |t| # If we have customizations use their status - if customizations.respond_to?(:keys) + if customizations.keys.length > 0 c = customizations[t.dmptemplate_id] # If the template was not customized then its unpublished if c.nil? diff --git a/app/models/org.rb b/app/models/org.rb index 1a41c1e..3052a22 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -104,6 +104,9 @@ return "None" end + def funder_only? + self.org_type == Org.org_type_values_for(:funder).min + end ## # returns the name of the organisation diff --git a/app/views/org_admin/templates/_edit_template.html.erb b/app/views/org_admin/templates/_edit_template.html.erb index a94815b..2dccb11 100644 --- a/app/views/org_admin/templates/_edit_template.html.erb +++ b/app/views/org_admin/templates/_edit_template.html.erb @@ -29,7 +29,7 @@ <% if template_hash[:live].nil? %> <%= _('Unpublished') %> <% elsif template_hash[:current].dirty? %> - <%= _('You have un-published changes') %> + <%= _('You have unpublished changes') %> <% else %> <%= _('Published') %> <% end %> diff --git a/app/views/org_admin/templates/_funder_templates_list.html.erb b/app/views/org_admin/templates/_funder_templates_list.html.erb index 30ad19a..a28e031 100644 --- a/app/views/org_admin/templates/_funder_templates_list.html.erb +++ b/app/views/org_admin/templates/_funder_templates_list.html.erb @@ -45,9 +45,9 @@ <%= _('Original funder template has changed!')%> <% elsif !template.published? %> - <%= b_label = _('Funder version is un-published') %> + <%= b_label = _('Funder version is unpublished') %> <% elsif customization.dirty? %> - <%= _('You have un-published changes') %> + <%= _('You have unpublished changes') %> <% elsif customization.published? %> <%= _('Published') %> <% else %> diff --git a/app/views/org_admin/templates/_show_template.html.erb b/app/views/org_admin/templates/_show_template.html.erb index f61514b..81b70f5 100644 --- a/app/views/org_admin/templates/_show_template.html.erb +++ b/app/views/org_admin/templates/_show_template.html.erb @@ -12,7 +12,7 @@ <%= _('Unpublished') %> <% elsif template_hash[:current].dirty? %> - <%= _('You have un-published changes') %> + <%= _('You have unpublished changes') %> <% else %> <%= _('Published') %> diff --git a/app/views/org_admin/templates/index.html.erb b/app/views/org_admin/templates/index.html.erb index 85e5e7c..70422d0 100644 --- a/app/views/org_admin/templates/index.html.erb +++ b/app/views/org_admin/templates/index.html.erb @@ -25,60 +25,53 @@
<%= _('There are currently no templates.') %>
- <% end %> + <%= paginable_renderise( + partial: 'templates_list', + controller: 'org_admin/templates', + action: 'all', + scope: all_templates, + locals: {current_org: current_org.id, published: published, scopes: scopes[:all], hide_actions: true}) %><%= _('There are currently no templates defined for your organisation.') %>
- <% end %> + <%= paginable_renderise( + partial: 'templates_list', + controller: 'org_admin/templates', + action: 'orgs', + scope: own_templates, + locals: {current_org: current_org.id, published: published, scopes: scopes[:orgs], hide_actions: false}) %><%= _('There are currently no customisable templates.') %>
- <% end %> -