Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aaronskiba opened this issue Apr 11, 2024 · 0 comments
Open

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

aaronskiba opened this issue Apr 11, 2024 · 0 comments
Labels
question Further information is requested

Comments

@aaronskiba
Copy link
Collaborator

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.1

Expected behaviour:

  • I'm not entirely sure, but I'm wondering if the "Download Monthly Usage" button should be hidden for Portage Network.

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/",
@aaronskiba aaronskiba added the question Further information is requested label Apr 11, 2024
@aaronskiba aaronskiba changed the title Handle Logic For "Download Monthly Usage" Button Visibilty Address Logic For "Download Monthly Usage" Button Visibilty Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant