Skip to content

Commit

Permalink
fix: Show only published publications and articles
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Nov 26, 2024
1 parent f25954b commit 2ef13e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/tpi/ascor_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ASCORController < TPIController
def index
@assessment_dates = ASCOR::Assessment.pluck(:assessment_date).uniq
@publications_and_articles = (
Publication.joins(:tags).includes(:tpi_sectors).where(tags: {name: 'ASCOR'}) +
NewsArticle.joins(:tags).where(tags: {name: 'ASCOR'})
Publication.published.joins(:tags).includes(:tpi_sectors).where(tags: {name: 'ASCOR'}) +
NewsArticle.published.joins(:tags).where(tags: {name: 'ASCOR'})
).uniq.sort_by(&:publication_date).reverse!.take(3)
ascor_page = TPIPage.find_by(slug: 'ascor')
@methodology_description = Content.find_by(page: ascor_page, code: 'methodology_description')
Expand Down
1 change: 1 addition & 0 deletions app/controllers/tpi/banks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BanksController < TPIController
def index
@assessment_dates = BankAssessment.select(:assessment_date).distinct.pluck(:assessment_date)
@publications_and_articles = TPISector.find_by(slug: 'banks')&.publications_and_articles || []
@publications_and_articles = @publications_and_articles.select { |pa| pa.publication_date <= Time.current }
bank_page = TPIPage.find_by(slug: 'banks-content')
@methodology_description = Content.find_by(
page: bank_page,
Expand Down
4 changes: 3 additions & 1 deletion app/views/tpi/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
<% @latest_researches.each_with_index do |research, index| %>
<div>
<%= link_to tpi_publication_download_file_path(slug: research.slug, format: format_of(research.file)), target: '_blank', class: 'research-box' do %>
<img src="<%= url_for(research.image) %>" />
<% if research.image.present? %>
<img src="<%= url_for(research.image) %>" />
<% end %>
<div class="research-box__title">
<% if research.author_image.present? %>
<img src="<%= url_for(research.author_image_thumbnail) %>" />
Expand Down

0 comments on commit 2ef13e7

Please sign in to comment.