From b8f40f047e2e327409a0a69a2b3d3b2306209b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Thu, 12 Jan 2023 16:27:38 +0100 Subject: [PATCH] summary in journals and volumes --- .../admin/research/journals/volumes_controller.rb | 2 +- app/controllers/admin/research/journals_controller.rb | 2 +- app/models/research/journal.rb | 1 + app/models/research/journal/volume.rb | 1 + app/views/admin/research/journals/_form.html.erb | 1 + app/views/admin/research/journals/show.html.erb | 1 + app/views/admin/research/journals/static.html.erb | 1 + app/views/admin/research/journals/volumes/_form.html.erb | 1 + app/views/admin/research/journals/volumes/show.html.erb | 1 + app/views/admin/research/journals/volumes/static.html.erb | 1 + db/migrate/20230112145505_add_summary_to_research_models.rb | 6 ++++++ db/schema.rb | 4 +++- 12 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20230112145505_add_summary_to_research_models.rb diff --git a/app/controllers/admin/research/journals/volumes_controller.rb b/app/controllers/admin/research/journals/volumes_controller.rb index 5d693ca97..f8395fa9e 100644 --- a/app/controllers/admin/research/journals/volumes_controller.rb +++ b/app/controllers/admin/research/journals/volumes_controller.rb @@ -58,7 +58,7 @@ class Admin::Research::Journals::VolumesController < Admin::Research::Journals:: def volume_params params.require(:research_journal_volume) .permit( - :title, :slug, :number, :keywords, :published, :published_at, :meta_description, :text, + :title, :slug, :number, :keywords, :published, :published_at, :meta_description, :summary, :text, :featured_image, :featured_image_infos, :featured_image_delete, :featured_image_alt, :featured_image_credit ) .merge(university_id: current_university.id) diff --git a/app/controllers/admin/research/journals_controller.rb b/app/controllers/admin/research/journals_controller.rb index b05662b96..6ccc4ead7 100644 --- a/app/controllers/admin/research/journals_controller.rb +++ b/app/controllers/admin/research/journals_controller.rb @@ -53,7 +53,7 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll def journal_params params.require(:research_journal) - .permit(:title, :meta_description, :issn, :access_token, :repository) + .permit(:title, :meta_description, :summary, :issn) .merge(university_id: current_university.id) end end diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb index e20d9e60b..2cf68b792 100644 --- a/app/models/research/journal.rb +++ b/app/models/research/journal.rb @@ -5,6 +5,7 @@ # id :uuid not null, primary key # issn :string # meta_description :text +# summary :text # title :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 858aad6ad..7954879f6 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -11,6 +11,7 @@ # published :boolean default(FALSE) # published_at :datetime # slug :string +# summary :text # text :text # title :string # created_at :datetime not null diff --git a/app/views/admin/research/journals/_form.html.erb b/app/views/admin/research/journals/_form.html.erb index 3573f57b2..1d9fbaa4a 100644 --- a/app/views/admin/research/journals/_form.html.erb +++ b/app/views/admin/research/journals/_form.html.erb @@ -7,6 +7,7 @@ <div class="card flex-fill w-100"> <div class="card-body"> <%= f.input :title %> + <%= render 'admin/application/summary/form', f: f, about: journal %> <%= f.input :issn %> </div> </div> diff --git a/app/views/admin/research/journals/show.html.erb b/app/views/admin/research/journals/show.html.erb index be32a34b3..4cf2893c0 100644 --- a/app/views/admin/research/journals/show.html.erb +++ b/app/views/admin/research/journals/show.html.erb @@ -11,6 +11,7 @@ <% if @journal.issn %><%= Research::Journal.human_attribute_name('issn') %> <%= @journal.issn %><% end %> <% end %> +<%= render 'admin/application/summary/show', about: @journal %> <div class="card mt-5"> <div class="card-header"> <div class="float-end"> diff --git a/app/views/admin/research/journals/static.html.erb b/app/views/admin/research/journals/static.html.erb index 278021cc4..51381c194 100644 --- a/app/views/admin/research/journals/static.html.erb +++ b/app/views/admin/research/journals/static.html.erb @@ -4,4 +4,5 @@ title: > issn: > <%= @about.issn %> <%= render 'admin/application/meta_description/static' %> +<%= render 'admin/application/summary/static' %> --- diff --git a/app/views/admin/research/journals/volumes/_form.html.erb b/app/views/admin/research/journals/volumes/_form.html.erb index 3bcfdafab..7d39bfe89 100644 --- a/app/views/admin/research/journals/volumes/_form.html.erb +++ b/app/views/admin/research/journals/volumes/_form.html.erb @@ -10,6 +10,7 @@ </div> <div class="card-body"> <%= f.input :title %> + <%= render 'admin/application/summary/form', f: f, about: volume %> <%= f.input :text, as: :summernote %> </div> </div> diff --git a/app/views/admin/research/journals/volumes/show.html.erb b/app/views/admin/research/journals/volumes/show.html.erb index 9d58f2d98..3294c87dc 100644 --- a/app/views/admin/research/journals/volumes/show.html.erb +++ b/app/views/admin/research/journals/volumes/show.html.erb @@ -2,6 +2,7 @@ <div class="row"> <div class="col-md-9"> + <%= render 'admin/application/summary/show', about: @volume %> <div class="card flex-fill w-100"> <div class="card-header"> <h2 class="card-title mb-0 h5"><%= t('content') %></h2> diff --git a/app/views/admin/research/journals/volumes/static.html.erb b/app/views/admin/research/journals/volumes/static.html.erb index ca5877031..284cefba7 100644 --- a/app/views/admin/research/journals/volumes/static.html.erb +++ b/app/views/admin/research/journals/volumes/static.html.erb @@ -8,5 +8,6 @@ keywords: > date: "<%= @about.published_at.iso8601 %>" <%= render 'admin/application/featured_image/static' %> <%= render 'admin/application/meta_description/static' %> +<%= render 'admin/application/summary/static' %> --- <%= prepare_html_for_static @about.text, @about.university %> diff --git a/db/migrate/20230112145505_add_summary_to_research_models.rb b/db/migrate/20230112145505_add_summary_to_research_models.rb new file mode 100644 index 000000000..6d46d872c --- /dev/null +++ b/db/migrate/20230112145505_add_summary_to_research_models.rb @@ -0,0 +1,6 @@ +class AddSummaryToResearchModels < ActiveRecord::Migration[7.0] + def change + add_column :research_journals, :summary, :text + add_column :research_journal_volumes, :summary, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 9f2c0bc74..15dd27a1b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_12_131744) do +ActiveRecord::Schema[7.0].define(version: 2023_01_12_145505) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -610,6 +610,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_131744) do t.boolean "published", default: false t.text "text" t.text "featured_image_credit" + t.text "summary" t.index ["research_journal_id"], name: "index_research_journal_volumes_on_research_journal_id" t.index ["university_id"], name: "index_research_journal_volumes_on_university_id" end @@ -621,6 +622,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_131744) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "issn" + t.text "summary" t.index ["university_id"], name: "index_research_journals_on_university_id" end -- GitLab