Skip to content

Commit

Permalink
do not show disabled materials on material index and provider show
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesndrs committed Dec 20, 2024
1 parent bcb7db9 commit 901b037
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/models/material.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ def self.facet_fields
field_list
end

def self.not_disabled
where('materials.visible is true')
end

def self.disabled
where('materials.visible is false')
end

def self.check_exists(material_params)
given_material = material_params.is_a?(Material) ? material_params : new(material_params)
material = nil
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_providers/_content_provider.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<% if content_provider.materials.length > 0 %>
<div><strong><%= pluralize(content_provider.materials.length, 'training material') %></strong></div>
<div><strong><%= pluralize(content_provider.materials.not_disabled.length, 'training material') %></strong></div>
<% end %>

<% if content_provider.events.length > 0 %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_providers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<div class="my-3">
<% resource_limit = 30 %>
<% materials = @content_provider.materials.from_verified_users.limit(resource_limit) %>
<% materials_count = @content_provider.materials.from_verified_users.count %>
<% materials = @content_provider.materials.from_verified_users.not_disabled.limit(resource_limit) %>
<% materials_count = @content_provider.materials.from_verified_users.not_disabled.count %>
<% upcoming_events = @content_provider.events.from_verified_users.not_finished.not_disabled.order(start: :asc) %>
<% past_events = @content_provider.events.from_verified_users.finished.not_disabled %>
<% events = upcoming_events.limit(resource_limit) %>
Expand Down
2 changes: 1 addition & 1 deletion lib/facets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Facets
SPECIAL = {
include_expired: ->(c) { c.name == 'Event' },
include_disabled: ->(c) { c.name == 'Event' },
include_disabled: ->(c) { c.name == 'Event' || c.name == 'Material' },
include_archived: ->(c) { c.name == 'Material' || c.name == 'LearningPath' },
days_since_scrape: ->(c) { c.method_defined?(:last_scraped) },
elixir: ->(c) { %w[Event Material ContentProvider].include?(c.name) },
Expand Down

0 comments on commit 901b037

Please sign in to comment.