diff --git a/Gemfile.lock b/Gemfile.lock index 720532eac..9ed7c3267 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -296,7 +296,7 @@ GEM mini_magick (4.11.0) mini_mime (1.1.5) mini_portile2 (2.8.6) - minitest (5.22.3) + minitest (5.23.1) msgpack (1.5.3) multi_json (1.15.0) net-imap (0.4.9.1) @@ -312,7 +312,7 @@ GEM net-protocol net-ssh (7.0.1) nio4r (2.7.0) - nokogiri (1.16.4) + nokogiri (1.16.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) optimist (3.0.1) @@ -338,7 +338,7 @@ GEM public_suffix (4.0.7) puma (5.6.8) nio4r (~> 2.0) - racc (1.7.3) + racc (1.8.0) rack (2.2.9) rack-cors (1.1.1) rack (>= 2.0.0) @@ -405,7 +405,8 @@ GEM actionpack (>= 5.2) railties (>= 5.2) retriable (3.1.2) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) roo (2.10.0) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) @@ -497,6 +498,7 @@ GEM sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) + strscan (3.1.0) super_diff (0.9.0) attr_extras (>= 6.2.4) diff-lcs @@ -543,7 +545,7 @@ GEM rails (>= 3.2.16) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.13) + zeitwerk (2.6.15) PLATFORMS ruby diff --git a/app/admin/news_article.rb b/app/admin/news_article.rb index f12cc1e6f..0e259c87d 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, :is_insight, + permit_params :title, :content, :publication_date, :is_insight, :is_event, :created_by_id, :updated_by_id, :short_description, :image, :keywords_string, tpi_sector_ids: [] @@ -33,6 +33,7 @@ image_tag(url_for(t.image)) if t.image.present? end row :is_insight + row :is_event row :updated_at row :updated_by row :created_at @@ -48,6 +49,7 @@ column :short_description column :publication_date column :is_insight + column :is_event actions end @@ -61,6 +63,7 @@ column :keywords, &:keywords_csv column :publication_date column :is_insight + column :is_event end form html: {'data-controller' => 'check-modified'} do |f| @@ -76,6 +79,7 @@ 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 + f.input :is_event end f.actions diff --git a/app/javascript/components/tpi/Filters.js b/app/javascript/components/tpi/Filters.js index a8922c03e..8d5d758cd 100644 --- a/app/javascript/components/tpi/Filters.js +++ b/app/javascript/components/tpi/Filters.js @@ -184,7 +184,7 @@ const Filters = ({ types, tags, sectors, resultsSize }) => {
-

Showing {resultsCount} items in All Publications and news

+

Showing {resultsCount} items in All Publications, news and events

<%= react_component("Filters", { - types: %w[Publications News Insights], + types: %w[Publications News Insights Events], tags: @tags, sectors: @sectors, resultsSize: @publications_and_articles_count diff --git a/app/views/tpi/search/index.html.erb b/app/views/tpi/search/index.html.erb index 5d003a2a1..dc0554afb 100644 --- a/app/views/tpi/search/index.html.erb +++ b/app/views/tpi/search/index.html.erb @@ -27,7 +27,7 @@ <% end %> <% if @publications_and_articles.any? %> -

Publications and news

+

Publications, news and events

<%= render 'tpi/publications/promoted', publications_and_articles: @publications_and_articles, count: @publications_and_articles.count %> <% end %>
diff --git a/db/migrate/20240527100352_add_is_event_to_news_articles.rb b/db/migrate/20240527100352_add_is_event_to_news_articles.rb new file mode 100644 index 000000000..dce8654e4 --- /dev/null +++ b/db/migrate/20240527100352_add_is_event_to_news_articles.rb @@ -0,0 +1,5 @@ +class AddIsEventToNewsArticles < ActiveRecord::Migration[6.1] + def change + add_column :news_articles, :is_event, :boolean, default: false + end +end diff --git a/db/structure.sql b/db/structure.sql index 4402487d8..5aebd1bb1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1558,7 +1558,8 @@ CREATE TABLE public.news_articles ( created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, is_insight boolean DEFAULT false, - short_description text + short_description text, + is_event boolean DEFAULT false ); @@ -4176,6 +4177,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20231207082211'), ('20240119084250'), ('20240202090401'), -('20240206094238'); +('20240206094238'), +('20240527100352'); diff --git a/db/test-dump.psql b/db/test-dump.psql index ba7329d74..fce6478ce 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 c45e89586..c67b49f56 100644 --- a/spec/controllers/admin/news_articles_controller_spec.rb +++ b/spec/controllers/admin/news_articles_controller_spec.rb @@ -38,7 +38,8 @@ title: 'My amazing title', short_description: 'My amazing short description', content: 'Test Content', - is_insight: true + is_insight: true, + is_event: true ) end @@ -52,6 +53,7 @@ expect(g.short_description).to eq(valid_params[:short_description]) expect(g.content).to eq(valid_params[:content]) expect(g.is_insight).to be_truthy + expect(g.is_event).to be_truthy end end diff --git a/spec/factories/news_articles.rb b/spec/factories/news_articles.rb index c9e577149..ff84662c3 100644 --- a/spec/factories/news_articles.rb +++ b/spec/factories/news_articles.rb @@ -12,6 +12,7 @@ # updated_at :datetime not null # is_insight :boolean default(FALSE) # short_description :text +# is_event :boolean default(FALSE) # FactoryBot.define do @@ -23,6 +24,7 @@ publication_date { '2019-11-29' } image { fixture_file_upload(Rails.root.join('spec', 'support', 'fixtures', 'files', 'test.jpg'), 'jpg') } is_insight { false } + is_event { false } association :created_by, factory: :admin_user updated_by { created_by } diff --git a/spec/models/news_article_spec.rb b/spec/models/news_article_spec.rb index d72d2eb8d..cfc2fb454 100644 --- a/spec/models/news_article_spec.rb +++ b/spec/models/news_article_spec.rb @@ -12,6 +12,7 @@ # updated_at :datetime not null # is_insight :boolean default(FALSE) # short_description :text +# is_event :boolean default(FALSE) # require 'rails_helper'