diff --git a/app/admin/news_article.rb b/app/admin/news_article.rb
index 8e9d5d5cc..b2de584e7 100644
--- a/app/admin/news_article.rb
+++ b/app/admin/news_article.rb
@@ -6,7 +6,7 @@
decorate_with NewsArticleDecorator
- permit_params :title, :content, :publication_date,
+ permit_params :title, :content, :publication_date, :is_insight,
:created_by_id, :updated_by_id,
:image, :keywords_string, tpi_sector_ids: []
@@ -30,6 +30,7 @@
row :image do |t|
image_tag(url_for(t.image)) if t.image.present?
end
+ row :is_insight
row :updated_at
row :updated_by
row :created_at
@@ -43,6 +44,7 @@
index do
column 'Title', :title_link
column :publication_date
+ column :is_insight
actions
end
@@ -54,6 +56,7 @@
column(:sectors) { |l| l.tpi_sectors.map(&:name).join(Rails.application.config.csv_options[:entity_sep]) }
column :keywords, &:keywords_csv
column :publication_date
+ column :is_insight
end
form html: {'data-controller' => 'check-modified'} do |f|
@@ -67,6 +70,7 @@
collection: TPISector.order(:name), input_html: {multiple: true}
f.input :keywords_string, label: 'Keywords', hint: t('hint.tag'), as: :tags, collection: Keyword.pluck(:name)
f.input :image, as: :file, input_html: {accept: 'image/*'}
+ f.input :is_insight
end
f.actions
diff --git a/app/admin/publication.rb b/app/admin/publication.rb
index 3b0587e54..2253d9819 100644
--- a/app/admin/publication.rb
+++ b/app/admin/publication.rb
@@ -7,7 +7,7 @@
decorate_with PublicationDecorator
permit_params :title, :author, :author_image, :short_description, :publication_date,
- :file, :image, :created_by_id, :updated_by_id,
+ :file, :image, :created_by_id, :updated_by_id, :summary,
:keywords_string, tpi_sector_ids: []
filter :title
@@ -20,6 +20,7 @@
attributes_table do
row :title
row :short_description
+ row :summary
row :author
row :author_image do |p|
if p.author_image.present?
@@ -63,6 +64,7 @@
f.input :author
f.input :author_image, as: :file, hint: preview_file_tag(f.object.author_image), input_html: {accept: 'image/*'}
f.input :short_description, as: :text
+ f.input :summary, as: :trix, embed_youtube: true
f.input :publication_date, as: :date_time_picker
f.input :tpi_sector_ids, label: 'Sectors', as: :select,
collection: TPISector.order(:name), input_html: {multiple: true}
diff --git a/app/assets/stylesheets/tpi/_publications.scss b/app/assets/stylesheets/tpi/_publications.scss
index c64d29eb4..e303d03f2 100644
--- a/app/assets/stylesheets/tpi/_publications.scss
+++ b/app/assets/stylesheets/tpi/_publications.scss
@@ -257,6 +257,16 @@ $max-lines: 3;
margin-bottom: 22px;
}
}
+
+ &__content-type {
+ color: $grey-dark;
+ margin-top: 10px;
+ font-size: $size-7;
+ border: 1px solid rgba($grey-dark, 0.5);
+ padding-left: $size-7;
+ padding-right: $size-7;
+ display: inline-block;
+ }
}
.publications__grid {
diff --git a/app/models/bank_assessment_indicator.rb b/app/models/bank_assessment_indicator.rb
index bb8b9d543..60be9b66c 100644
--- a/app/models/bank_assessment_indicator.rb
+++ b/app/models/bank_assessment_indicator.rb
@@ -9,6 +9,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# comment :text
+# is_placeholder :boolean default(FALSE)
#
class BankAssessmentIndicator < ApplicationRecord
INDICATOR_TYPES = %w[area sub_area indicator sub_indicator].freeze
diff --git a/app/models/news_article.rb b/app/models/news_article.rb
index a9822a21e..0b2f51561 100644
--- a/app/models/news_article.rb
+++ b/app/models/news_article.rb
@@ -10,6 +10,7 @@
# updated_by_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
+# is_insight :boolean default(FALSE)
#
class NewsArticle < ApplicationRecord
@@ -23,6 +24,8 @@ class NewsArticle < ApplicationRecord
has_and_belongs_to_many :tpi_sectors
scope :published, -> { where('publication_date <= ?', DateTime.now) }
+ scope :insights, -> { where(is_insight: true) }
+ scope :not_insights, -> { where(is_insight: false) }
validates_presence_of :title, :content, :publication_date
diff --git a/app/models/publication.rb b/app/models/publication.rb
index be6642574..931de762a 100644
--- a/app/models/publication.rb
+++ b/app/models/publication.rb
@@ -14,6 +14,7 @@
# updated_at :datetime not null
# author :string
# slug :text not null
+# summary :text
#
class Publication < ApplicationRecord
diff --git a/app/services/queries/tpi/news_publications_query.rb b/app/services/queries/tpi/news_publications_query.rb
index 69bb0d941..45b56bdf0 100644
--- a/app/services/queries/tpi/news_publications_query.rb
+++ b/app/services/queries/tpi/news_publications_query.rb
@@ -7,7 +7,7 @@ class NewsPublicationsQuery
attr_accessor :tags, :sectors, :types
def call
- (publications + news).uniq.sort_by(&:publication_date).reverse!
+ (publications + news + insights).uniq.sort_by(&:publication_date).reverse!
end
private
@@ -21,7 +21,13 @@ def publications
def news
return NewsArticle.none if types.present? && !types.include?('News')
- filter_scope(NewsArticle.published)
+ filter_scope(NewsArticle.published.not_insights)
+ end
+
+ def insights
+ return NewsArticle.none if types.present? && !types.include?('Insights')
+
+ filter_scope(NewsArticle.published.insights)
end
def filter_scope(scope)
diff --git a/app/views/tpi/publications/_list.html.erb b/app/views/tpi/publications/_list.html.erb
index 4bf5de83f..d11cbf1c3 100644
--- a/app/views/tpi/publications/_list.html.erb
+++ b/app/views/tpi/publications/_list.html.erb
@@ -8,7 +8,11 @@
<% if publication.is_a?(Publication) %>
- <%= link_to publication.title, tpi_publication_path(id: publication.slug), class: 'link is-strong' %>
+ <% if publication.summary.present? %>
+ <%= link_to publication.title, tpi_publication_path(id: publication.slug), class: 'link is-strong' %>
+ <% else %>
+ <%= link_to publication.title, tpi_publication_download_file_path(slug: publication.slug), target: '_blank', class: 'link is-strong' %>
+ <% end %>
<% else %>
<%= link_to publication.title, show_news_article_tpi_publication_path(id: publication.id), class: "link is-strong" %>
<% end %>
@@ -25,6 +29,13 @@
<% end %>
+
+ <% if publication.is_a?(NewsArticle) %>
+ <%= publication.is_insight? ? 'Insights' : 'News' %>
+ <% else %>
+ Publications
+ <% end %>
+
<% if publication.keywords.any? || publication.tpi_sectors.any? %>
<% publication.tags_and_sectors.each do |tag| %>
diff --git a/app/views/tpi/publications/index.html.erb b/app/views/tpi/publications/index.html.erb
index 5d6fc2489..26cbe0864 100644
--- a/app/views/tpi/publications/index.html.erb
+++ b/app/views/tpi/publications/index.html.erb
@@ -8,7 +8,7 @@
<%= react_component("Filters", {
- types: %w[Publications News],
+ types: %w[Publications News Insights],
tags: @tags,
sectors: @sectors,
resultsSize: @publications_and_articles_count
diff --git a/app/views/tpi/publications/show.html.erb b/app/views/tpi/publications/show.html.erb
index d21e300c2..408a04200 100644
--- a/app/views/tpi/publications/show.html.erb
+++ b/app/views/tpi/publications/show.html.erb
@@ -9,7 +9,7 @@
<% if @publication.image.present? %>
-
<%= image_tag(@publication.image) %>
+
<%= image_tag(@publication.image) %>
<% end %>
<%= @publication.short_description %>
@@ -20,6 +20,9 @@
<% end %>
<% end %>
+
+ <%= @publication.summary&.html_safe %>
+
<%= link_to 'Download file', tpi_publication_download_file_path(slug: @publication.slug), target: '_blank', class: 'button is-primary' %>
diff --git a/db/migrate/20231023101859_add_is_insight_to_news_articles.rb b/db/migrate/20231023101859_add_is_insight_to_news_articles.rb
new file mode 100644
index 000000000..ba04d5af6
--- /dev/null
+++ b/db/migrate/20231023101859_add_is_insight_to_news_articles.rb
@@ -0,0 +1,5 @@
+class AddIsInsightToNewsArticles < ActiveRecord::Migration[6.1]
+ def change
+ add_column :news_articles, :is_insight, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20231023120255_add_summary_to_publications.rb b/db/migrate/20231023120255_add_summary_to_publications.rb
new file mode 100644
index 000000000..1a9545509
--- /dev/null
+++ b/db/migrate/20231023120255_add_summary_to_publications.rb
@@ -0,0 +1,5 @@
+class AddSummaryToPublications < ActiveRecord::Migration[6.1]
+ def change
+ add_column :publications, :summary, :text
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 9122b12ed..fc0008d5d 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -1548,7 +1548,8 @@ CREATE TABLE public.news_articles (
created_by_id bigint,
updated_by_id bigint,
created_at timestamp(6) without time zone NOT NULL,
- updated_at timestamp(6) without time zone NOT NULL
+ updated_at timestamp(6) without time zone NOT NULL,
+ is_insight boolean DEFAULT false
);
@@ -1633,7 +1634,8 @@ CREATE TABLE public.publications (
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
author character varying,
- slug text NOT NULL
+ slug text NOT NULL,
+ summary text
);
@@ -4158,6 +4160,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230915064402'),
('20230920083300'),
('20230926075145'),
-('20230927112905');
+('20230927112905'),
+('20231023101859'),
+('20231023120255');
diff --git a/db/test-dump.psql b/db/test-dump.psql
index 4782cce05..aad693c09 100644
Binary files a/db/test-dump.psql and b/db/test-dump.psql differ
diff --git a/spec/controllers/admin/news_articles_controller_spec.rb b/spec/controllers/admin/news_articles_controller_spec.rb
index 08c3279dc..c2993ed47 100644
--- a/spec/controllers/admin/news_articles_controller_spec.rb
+++ b/spec/controllers/admin/news_articles_controller_spec.rb
@@ -36,7 +36,8 @@
attributes_for(
:news_article,
title: 'My amazing title',
- content: 'Test Content'
+ content: 'Test Content',
+ is_insight: true
)
end
@@ -48,6 +49,7 @@
last_news_article_created.tap do |g|
expect(g.title).to eq(valid_params[:title])
expect(g.content).to eq(valid_params[:content])
+ expect(g.is_insight).to be_truthy
end
end
diff --git a/spec/controllers/admin/publications_controller_spec.rb b/spec/controllers/admin/publications_controller_spec.rb
index 64b1270fd..4e571d3ce 100644
--- a/spec/controllers/admin/publications_controller_spec.rb
+++ b/spec/controllers/admin/publications_controller_spec.rb
@@ -36,7 +36,8 @@
attributes_for(
:publication,
title: 'My amazing title',
- short_description: 'Test short_description'
+ short_description: 'Test short_description',
+ summary: 'Test summary'
)
end
@@ -48,6 +49,7 @@
last_publication_created.tap do |g|
expect(g.title).to eq(valid_params[:title])
expect(g.short_description).to eq(valid_params[:short_description])
+ expect(g.summary).to eq(valid_params[:summary])
end
end
diff --git a/spec/factories/bank_assessment_indicators.rb b/spec/factories/bank_assessment_indicators.rb
index 343d66493..5a2a3bc5f 100644
--- a/spec/factories/bank_assessment_indicators.rb
+++ b/spec/factories/bank_assessment_indicators.rb
@@ -9,6 +9,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# comment :text
+# is_placeholder :boolean default(FALSE)
#
FactoryBot.define do
factory :bank_assessment_indicator, class: BankAssessmentIndicator do
diff --git a/spec/factories/news_articles.rb b/spec/factories/news_articles.rb
index 8102b545b..9bef6a7a1 100644
--- a/spec/factories/news_articles.rb
+++ b/spec/factories/news_articles.rb
@@ -10,6 +10,7 @@
# updated_by_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
+# is_insight :boolean default(FALSE)
#
FactoryBot.define do
@@ -19,6 +20,7 @@
tpi_sectors { |a| [a.association(:tpi_sector)] }
publication_date { '2019-11-29' }
image { fixture_file_upload(Rails.root.join('spec', 'support', 'fixtures', 'files', 'test.jpg'), 'jpg') }
+ is_insight { false }
association :created_by, factory: :admin_user
updated_by { created_by }
diff --git a/spec/factories/publications.rb b/spec/factories/publications.rb
index 84ce9500a..e9a77f1d1 100644
--- a/spec/factories/publications.rb
+++ b/spec/factories/publications.rb
@@ -14,6 +14,7 @@
# updated_at :datetime not null
# author :string
# slug :text not null
+# summary :text
#
FactoryBot.define do
@@ -23,6 +24,7 @@
title { 'MyString' }
author { 'Author' }
short_description { 'MyText' }
+ summary { 'MyText' }
publication_date { '2019-12-02' }
file { fixture_file_upload(Rails.root.join('spec', 'support', 'fixtures', 'files', 'test.pdf'), 'pdf') }
diff --git a/spec/models/bank_assessment_indicator_spec.rb b/spec/models/bank_assessment_indicator_spec.rb
index 6f6c57e81..1f1a15046 100644
--- a/spec/models/bank_assessment_indicator_spec.rb
+++ b/spec/models/bank_assessment_indicator_spec.rb
@@ -9,6 +9,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# comment :text
+# is_placeholder :boolean default(FALSE)
#
require 'rails_helper'
diff --git a/spec/models/news_article_spec.rb b/spec/models/news_article_spec.rb
index 5ee1f09fd..074ab6c30 100644
--- a/spec/models/news_article_spec.rb
+++ b/spec/models/news_article_spec.rb
@@ -10,6 +10,7 @@
# updated_by_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
+# is_insight :boolean default(FALSE)
#
require 'rails_helper'
diff --git a/spec/models/publication_spec.rb b/spec/models/publication_spec.rb
index 89e6e09ec..6a8635388 100644
--- a/spec/models/publication_spec.rb
+++ b/spec/models/publication_spec.rb
@@ -14,6 +14,7 @@
# updated_at :datetime not null
# author :string
# slug :text not null
+# summary :text
#
require 'rails_helper'