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

Address Logic For "Download Monthly Usage" Button Visibilty #722

Open aaronskiba opened 5 months ago

aaronskiba commented 5 months ago

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

Expected behaviour:

Actual behaviour:

app/views/usage/_total_usage.html.erb

  <% unless @funder.present? %>
    <div class="col-md-3">
      <%= link_to usage_org_statistics_path(sep: ",", filtered: @filtered), class: 'stat btn btn-default pull-right', role: 'button', target: '_blank' do %>
        <%= _('Download Monthly Usage') %> <i class="fas fa-download" aria-hidden="true"></i>
      <% end %>
    </div>
  <% end %>

app/controllers/usage_controller.rb

@funder = current_user.org.funder?

app/models/org.rb

  # Define Bit Field values
  # Column org_type
  has_flags 1 => :institution,
            2 => :funder,
            3 => :organisation,
            4 => :research_institute,
            5 => :project,
            6 => :school,
            column: 'org_type',
            check_for_column: !Rails.env.test?

rails console shows that Portage Network is the only Org where Org.funder? evaluates to true

aaron@ubuntu:~/Documents/GitHub/roadmap
$ rails c
Running via Spring preloader in process 1210283
Loading development environment (Rails 6.1.7.6)
irb: warn: can't alias context from irb_context.
3.0.5 :001 > Org.funder.count
   (2.2ms)  SELECT COUNT(*) FROM "orgs" WHERE (("orgs"."org_type" in (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63)))
 => 1 
3.0.5 :002 > Org.funder
  Org Load (2.1ms)  SELECT "orgs".* FROM "orgs" WHERE (("orgs"."org_type" in (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63)))
 => 
[#<Org:0x000064e55c559230
  id: 8,
  name: "Portage Network",
  abbreviation: "Portage",
  target_url: "https://portagenetwork.ca/",