diff --git a/app/controllers/admin/communication/extranets/posts/categories_controller.rb b/app/controllers/admin/communication/extranets/posts/categories_controller.rb index d86b9fba380bfad2a8999c501b6b7525b11921f1..181259aec816ba1f9600327913d26dddcc344a02 100644 --- a/app/controllers/admin/communication/extranets/posts/categories_controller.rb +++ b/app/controllers/admin/communication/extranets/posts/categories_controller.rb @@ -7,6 +7,7 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Comm end def show + @posts = @category.posts.ordered.page params[:page] breadcrumb end diff --git a/app/controllers/admin/communication/extranets/posts_controller.rb b/app/controllers/admin/communication/extranets/posts_controller.rb index dfbeada39a10887f4d3d08924fbf69e3cc178907..c63ad06a8a6d07e8e42e4cbfcca287b6907c4ff1 100644 --- a/app/controllers/admin/communication/extranets/posts_controller.rb +++ b/app/controllers/admin/communication/extranets/posts_controller.rb @@ -69,7 +69,7 @@ class Admin::Communication::Extranets::PostsController < Admin::Communication::E :title, :summary, :text, :published, :published_at, :slug, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, - :author_id + :author_id, :category_id ) .merge( university_id: current_university.id diff --git a/app/models/communication/extranet/post.rb b/app/models/communication/extranet/post.rb index 458d5f711dd5b5bd81bc7be29540e8980a73691d..9161c77213f9625cc114e29a1a9450ed92086f28 100644 --- a/app/models/communication/extranet/post.rb +++ b/app/models/communication/extranet/post.rb @@ -41,6 +41,7 @@ class Communication::Extranet::Post < ApplicationRecord include WithUniversity belongs_to :author, class_name: 'University::Person', optional: true + belongs_to :category, class_name: 'Communication::Extranet::Post::Category', optional: true belongs_to :extranet, class_name: 'Communication::Extranet' validates :title, presence: true diff --git a/app/models/communication/extranet/post/category.rb b/app/models/communication/extranet/post/category.rb index d02d4316b55e8706ae1d4b04f0443640d120198b..d87ec5b7f0d8cce3e2ef67f1adcae3605c9bde88 100644 --- a/app/models/communication/extranet/post/category.rb +++ b/app/models/communication/extranet/post/category.rb @@ -24,6 +24,7 @@ class Communication::Extranet::Post::Category < ApplicationRecord include WithUniversity belongs_to :extranet, class_name: 'Communication::Extranet' + has_many :posts scope :ordered, -> { order(:name) } diff --git a/app/views/admin/communication/extranets/posts/_form.html.erb b/app/views/admin/communication/extranets/posts/_form.html.erb index e82335fbeb15088be8e18bc6e108175dcef5957c..d263109d38214c1ac9ba3561d3838337293db240 100644 --- a/app/views/admin/communication/extranets/posts/_form.html.erb +++ b/app/views/admin/communication/extranets/posts/_form.html.erb @@ -12,16 +12,14 @@ <div class="col-md-4"> <%= osuny_panel t('metadata') do %> <% if can? :publish, post %> - <div class="row pure__row--small"> - <div class="col-6"> - <%= f.input :published %> - </div> - </div> + <%= f.input :published %> <%= f.input :published_at, html5: true, as: :date %> <% end %> + <%= f.association :category, + collection: @extranet.post_categories.ordered %> <%= f.association :author, - collection: @extranet.connected_persons.ordered, - label_method: :to_s_alphabetical %> + collection: @extranet.connected_persons.ordered, + label_method: :to_s_alphabetical %> <%= f.input :slug, as: :string, input_html: post.persisted? ? {} : { diff --git a/app/views/admin/communication/extranets/posts/categories/show.html.erb b/app/views/admin/communication/extranets/posts/categories/show.html.erb index de73ef2f7ac1c40360ebfb669fead139480a09a4..30f2bd037402f50911dbb153e9453cbcd7dcdfb9 100644 --- a/app/views/admin/communication/extranets/posts/categories/show.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/show.html.erb @@ -1,12 +1,8 @@ <% content_for :title, @category %> <%= render 'admin/communication/extranets/sidebar' do %> - <div class="row"> - <div class="col-xl-8"> - </div> - <div class="col-xl-4"> - </div> - </div> + <%= render 'admin/communication/extranets/posts/list', posts: @posts %> + <%= paginate @posts, theme: 'bootstrap-5' %> <% end %> <% content_for :action_bar_left do %> diff --git a/app/views/admin/communication/extranets/posts/show.html.erb b/app/views/admin/communication/extranets/posts/show.html.erb index ad9c804d175b4e4646f32224c592078f240ca9f0..a4aa85eec80ed99554224e3cdb473d32c1e71440 100644 --- a/app/views/admin/communication/extranets/posts/show.html.erb +++ b/app/views/admin/communication/extranets/posts/show.html.erb @@ -25,6 +25,10 @@ </p> </div> </div> + <% if @post.category %> + <%= osuny_label Communication::Extranet::Post.human_attribute_name('category') %> + <p><%= link_to @post.category, [:admin, @post.category] %></p> + <% end %> <% if @post.author %> <%= osuny_label Communication::Extranet::Post.human_attribute_name('author') %> <p><%= @post.author %></p> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b3f982592507509884c520b7f7baed84efcc2b14..6d452571ac0ac8418b395fd8e43f9b6bbea89663 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -90,6 +90,7 @@ en: published_at: Publication date communication/extranet/post: author: Author + category: Category featured_image: Featured image featured_image_alt: Alt text featured_image_credit: Credit diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index f0ce1b4830ebcfe55f8adc243ee4a01229a657e6..2322491e709931f8d09738479b70d972d35ead3e 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -90,6 +90,7 @@ fr: published_at: Date de publication communication/extranet/post: author: Auteur·rice + category: Catégorie featured_image: Image à la une featured_image_alt: Texte alternatif featured_image_credit: Crédit