Skip to content
Snippets Groups Projects
Commit cc38b449 authored by pabois's avatar pabois
Browse files

filtres

parent 064e23af
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web
before_action :load_filters, only: :index
has_scope :for_search_term
has_scope :for_author
has_scope :for_category
has_scope :for_pinned
def index
@posts = apply_scopes(@posts).ordered.page params[:page]
......
......@@ -68,6 +68,9 @@ class Communication::Website::Post < ApplicationRecord
scope :published, -> { where(published: true) }
scope :ordered, -> { order(published_at: :desc, created_at: :desc) }
scope :recent, -> { order(published_at: :desc).limit(5) }
scope :for_author, -> (author_id) { where(author_id: author_id) }
scope :for_category, -> (category_id) { } # TODO Sebou
scope :for_pinned, -> (pinned) { where(pinned: pinned == 'true') } # TODO Sebou
scope :for_search_term, -> (term) {
where("
unaccent(communication_website_posts.description) ILIKE unaccent(:term) OR
......
......@@ -5,7 +5,7 @@ module Filters
add_search
add :for_author, website.authors.ordered, I18n.t('filters.attributes.element', element: I18n.t('activerecord.attributes.communication/website/post.author').downcase)
add :for_category, website.categories, I18n.t('filters.attributes.element', element: I18n.t('activerecord.models.communication/website/category.one').downcase), false, true
add :for_pinned, [{ to_s: I18n.t('true'), id: 'true' }, { to_s: I18n.t('false'), id: 'false' }], I18n.t('filters.attributes.element', element: I18n.t('admin.communication.website.post.pinned_status').downcase)
end
end
end
......@@ -202,6 +202,8 @@ en:
delete_special_page_notice: Can't delete this page
is_special_page: "This is a page with a special behaviour:"
structure: Structure
post:
pinned_status: Pinned status
communication:
authors:
one: Author
......
......@@ -204,6 +204,8 @@ fr:
delete_special_page_notice: Impossible de supprimer cette page
is_special_page: "Ceci est une page avec un comportement spécial :"
structure: Arborescence
post:
pinned_status: Mise en avant
communication:
authors:
one: Auteur·rice
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment