diff --git a/app/controllers/admin/research/journal/volumes_controller.rb b/app/controllers/admin/research/journal/volumes_controller.rb index 5c9f49db20aa8bddcaa1b63db1dffa5caeac5693..c470f7e8094cc74912ac79407e66af0bd5e90fb4 100644 --- a/app/controllers/admin/research/journal/volumes_controller.rb +++ b/app/controllers/admin/research/journal/volumes_controller.rb @@ -56,7 +56,7 @@ class Admin::Research::Journal::VolumesController < Admin::Research::Journal::Ap params.require(:research_journal_volume) .permit( :title, :slug, :number, :keywords, :published_at, :description, - :cover, :cover_infos, :cover_delete, :cover_alt + :featured_image, :featured_image_infos, :featured_image_delete, :featured_image_alt ) .merge(university_id: current_university.id) end diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index fd9764617a10e625e3a5212e3be47d9dad407c37..8f66ce3e62bb448cd45433695d3ddaff584522d5 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -3,8 +3,8 @@ # Table name: research_journal_volumes # # id :uuid not null, primary key -# cover_alt :string # description :text +# featured_image_alt :string # keywords :text # number :integer # published_at :date @@ -29,7 +29,7 @@ class Research::Journal::Volume < ApplicationRecord include WithGit include WithMedia - has_one_attached_deletable :cover + has_one_attached_deletable :featured_image belongs_to :university belongs_to :journal, foreign_key: :research_journal_id @@ -39,10 +39,6 @@ class Research::Journal::Volume < ApplicationRecord scope :ordered, -> { order(number: :desc, published_at: :desc) } - def cover_path - "/assets/img/volumes/#{id}#{cover.filename.extension_with_delimiter}" - end - def website journal.website end diff --git a/app/views/admin/research/journal/volumes/_form.html.erb b/app/views/admin/research/journal/volumes/_form.html.erb index dff3da118cd2d5c9eaeb4183e9ddaf7903ac90c3..0b53bf2925635413346a07237845b8101d9d7b13 100644 --- a/app/views/admin/research/journal/volumes/_form.html.erb +++ b/app/views/admin/research/journal/volumes/_form.html.erb @@ -13,12 +13,12 @@ class: 'js-slug-input', data: { source: '#research_journal_volume_title' } } %> - <%= f.input :cover, + <%= f.input :featured_image, as: :single_deletable_file, input_html: { accept: '.jpg,.jpeg,.png' }, preview: 200, direct_upload: true %> - <%= f.input :cover_alt %> + <%= f.input :featured_image_alt %> <%= f.input :description, input_html: { rows: 10 } %> </div> </div> diff --git a/app/views/admin/research/journal/volumes/show.html.erb b/app/views/admin/research/journal/volumes/show.html.erb index 68e885b99d14da18b505e989277412b827a055e6..403477a987f7de9db0da36b6d50b1cc7391be1f5 100644 --- a/app/views/admin/research/journal/volumes/show.html.erb +++ b/app/views/admin/research/journal/volumes/show.html.erb @@ -28,13 +28,13 @@ <p><%= l @volume.published_at.to_time, format: :date_with_explicit_month if @volume.published_at %></p> </div> </div> - <% if @volume.cover.attached? %> + <% if @volume.featured_image.attached? %> <div class="card"> <div class="card-header"> - <h2 class="card-title"><%= Research::Journal::Volume.human_attribute_name('cover') %></h2> + <h2 class="card-title"><%= Research::Journal::Volume.human_attribute_name('featured_image') %></h2> </div> <div class="card-body"> - <%= kamifusen_tag @volume.cover, class: 'img-fluid' %> + <%= kamifusen_tag @volume.featured_image, class: 'img-fluid' %> </div> </div> <% end %> diff --git a/app/views/admin/research/journal/volumes/static.html.erb b/app/views/admin/research/journal/volumes/static.html.erb index a90daf5835c9072cbf121e8460787100f6d0839d..43be3b9d7298727503b8335111b8f97c0f6bf749 100644 --- a/app/views/admin/research/journal/volumes/static.html.erb +++ b/app/views/admin/research/journal/volumes/static.html.erb @@ -4,9 +4,9 @@ number: <%= @volume.number %> issn: "<%= @volume.journal.issn %>" keywords: "<%= @volume.keywords %>" date: "<%= @volume.published_at %>" -<% if @volume.cover.attached? %> -image: "<%= @volume.cover.blob.id %>" -image_alt: "<%= @volume.cover_alt %>" +<% if @volume.featured_image.attached? %> +image: "<%= @volume.featured_image.blob.id %>" +image_alt: "<%= @volume.featured_image_alt %>" <% end %> articles: <% @volume.articles.each do |article| %> diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index eeb3d4532867969913bdf35cd7a4e126257509a3..795cc6f972d2a2f4edf3aeb75fa361b3b3b9b44f 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -27,7 +27,7 @@ en: text: Text title: Title research/journal/volume: - cover: Cover + featured_image: Cover featured_image_alt: Alt text description: Description keywords: Keywords diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index 10719c2d30e64a53d5af5b897d571c85e60e7ca5..df48aabfb290845b60937959d574fefa5baa9ee6 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -27,8 +27,8 @@ fr: text: Texte title: Titre research/journal/volume: - cover: Couverture - cover_alt: Texte alternatif + featured_image: Couverture + featured_image_alt: Texte alternatif description: Description keywords: Mots clés number: Numéro diff --git a/db/migrate/20220107094053_rename_cover_to_featured_image_for_volumes.rb b/db/migrate/20220107094053_rename_cover_to_featured_image_for_volumes.rb new file mode 100644 index 0000000000000000000000000000000000000000..cfca960bf0e014f71ca79ff01fdea4c0b7606c3b --- /dev/null +++ b/db/migrate/20220107094053_rename_cover_to_featured_image_for_volumes.rb @@ -0,0 +1,5 @@ +class RenameCoverToFeaturedImageForVolumes < ActiveRecord::Migration[6.1] + def change + rename_column :research_journal_volumes, :cover_alt, :featured_image_alt + end +end diff --git a/db/schema.rb b/db/schema.rb index b8e59bfdb2fe32620e035ad58b35db13a791e2b1..0271d56506cd95bbd33ce4d258f38011215c180c 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.define(version: 2022_01_06_134525) do +ActiveRecord::Schema.define(version: 2022_01_07_094053) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -465,7 +465,7 @@ ActiveRecord::Schema.define(version: 2022_01_06_134525) do t.text "description" t.text "keywords" t.string "slug" - t.string "cover_alt" + t.string "featured_image_alt" 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