portagenetwork / roadmap

Developed by the the Alliance in collaboration with University of Alberta, DMP Assistant a data management planning tool, forking the DMP Roadmap codebase
MIT License
6 stars 1 forks source link

Examine Usage of `Org.funder_only?` Throughout Codebase #756

Closed aaronskiba closed 1 month ago

aaronskiba commented 1 month ago

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0) 4.0.2+portage-4.0.3

Explanation

The following method within app/models/org.rb evaluates to false for all organizations currently in DMP Assistant's db.

  def funder_only?
    org_type == Org.org_type_values_for(:funder).min
  end
2.7.6 :006 > Org.where(org_type: Org.org_type_values_for(:funder).min).count
   (2.1ms)  SELECT COUNT(*) FROM "orgs" WHERE "orgs"."org_type" = $1  [["org_type", 2]]
 => 0

Given the problems this created for issue https://github.com/portagenetwork/roadmap/issues/755, the usage of this method should be examined throughout the codebase.

aaronskiba commented 1 month ago

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

<% if current_user.org.funder? && !current_user.org.funder_only? %>
  <!-- If the Org is a funder and another org type then allow then to set the visibility -->
  <div class="form-group col-xs-8">
    <%= f.label _('Visibility'), class: 'control-label' %>

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

  <% if current_user.org.funder? && !current_user.org.funder_only? %>
    <!-- If the Org is a funder and another org type then allow then to set the visibility -->
    <dt><%= _('Visibility') %></dt>
    <dd>
      <% if template.visibility == 'organisationally_visible' %>
        <%= _('for internal %{org_name} use only') % {org_name: template.org.name} %>
      <% else %>
        <%=  _('available to the public') + (template.published? ? '' : ' (once published)') %>
      <% end %>
    </dd>
  <% end %>

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

      <% if !current_user.org.funder_only? %>
        <li role="presentation"
            class="<%= action_name == 'customisable' ? 'active' : '' %>">
          <%= link_to(_('Customisable Templates'),
              customisable_org_admin_templates_path, { role: 'tab' }) %>
        </li>
      <% end %>
aaronskiba commented 1 month ago

As long as we aren't changing Portage Network to be a "funder only" Org, there shouldn't be any unwanted behaviour here.