From e8abe81edb2e4a3da82b6d73ae8d23d9b787c17c Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Fri, 17 Dec 2021 12:36:24 +0100 Subject: [PATCH] pin in posts --- .../admin/communication/website/posts_controller.rb | 2 +- app/models/communication/website/post.rb | 1 + app/views/admin/communication/website/posts/_form.html.erb | 1 + app/views/admin/communication/website/posts/jekyll.html.erb | 1 + config/locales/communication/en.yml | 1 + config/locales/communication/fr.yml | 1 + ...0211217112923_add_pinned_to_communication_website_post.rb | 5 +++++ db/schema.rb | 3 ++- 8 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20211217112923_add_pinned_to_communication_website_post.rb diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb index e7fafd1c7..f5bc2541f 100644 --- a/app/controllers/admin/communication/website/posts_controller.rb +++ b/app/controllers/admin/communication/website/posts_controller.rb @@ -61,7 +61,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def post_params params.require(:communication_website_post) - .permit(:university_id, :website_id, :title, :description, :text, :published, :published_at, :featured_image, :featured_image_delete, :featured_image_infos, :slug, :author_id, category_ids: []) + .permit(:university_id, :website_id, :title, :description, :text, :published, :published_at, :featured_image, :featured_image_delete, :featured_image_infos, :slug, :author_id, :pinned, category_ids: []) .merge(university_id: current_university.id) end end diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index b0fff7941..5dfedbc68 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -6,6 +6,7 @@ # description :text # github_path :text # old_text :text +# pinned :boolean default(FALSE) # published :boolean default(FALSE) # published_at :datetime # slug :text diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index 7e9244dcf..9b7fddc98 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -26,6 +26,7 @@ } %> <%= f.input :published %> <%= f.input :published_at, html5: true %> + <%= f.input :pinned %> <%= f.association :author, collection: current_university.members.authors.ordered %> <%= f.association :categories, as: :check_boxes, diff --git a/app/views/admin/communication/website/posts/jekyll.html.erb b/app/views/admin/communication/website/posts/jekyll.html.erb index 5bdba6bf1..3cab08858 100644 --- a/app/views/admin/communication/website/posts/jekyll.html.erb +++ b/app/views/admin/communication/website/posts/jekyll.html.erb @@ -2,6 +2,7 @@ title: "<%= @post.title %>" date: <%= @post.published_at %> UTC slug: "<%= @post.slug %>" +pinned: <%= @post.pinned %> author: "<%= @post.author_id %>" <% if @post.categories.any? %> categories: diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index c7dc5a884..efc691bcf 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -94,6 +94,7 @@ en: categories: Categories description: Description (SEO) featured_image: Featured image + pinned: Pinned? published: Published ? published_at: Publication date slug: Slug diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 80b8097fb..43725064e 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -84,6 +84,7 @@ fr: categories: Catégories description: Description (SEO) featured_image: Image à la une + pinned: Mis en avant ? published: Publié ? published_at: Date de publication slug: Slug diff --git a/db/migrate/20211217112923_add_pinned_to_communication_website_post.rb b/db/migrate/20211217112923_add_pinned_to_communication_website_post.rb new file mode 100644 index 000000000..60d469e5b --- /dev/null +++ b/db/migrate/20211217112923_add_pinned_to_communication_website_post.rb @@ -0,0 +1,5 @@ +class AddPinnedToCommunicationWebsitePost < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_posts, :pinned, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index f88c9b41c..603e00054 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: 2021_12_15_133833) do +ActiveRecord::Schema.define(version: 2021_12_17_112923) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -321,6 +321,7 @@ ActiveRecord::Schema.define(version: 2021_12_15_133833) do t.text "slug" t.text "github_path" t.uuid "author_id" + t.boolean "pinned", default: false t.index ["author_id"], name: "index_communication_website_posts_on_author_id" t.index ["communication_website_id"], name: "index_communication_website_posts_on_communication_website_id" t.index ["university_id"], name: "index_communication_website_posts_on_university_id" -- GitLab