Merge pull request #352 from abf/rosa-build:351-ability-to-search-by-package-name-in-advisory-list
#351: Ability to search by package name in advisory list
This commit is contained in:
commit
89a90bda02
|
@ -5,9 +5,8 @@ class AdvisoriesController < ApplicationController
|
|||
authorize_resource
|
||||
|
||||
def index
|
||||
@advisories = @advisories.scoped(include: :platforms)
|
||||
@advisories = @advisories.search_by_id(params[:q]) if params[:q]
|
||||
@advisories = @advisories.paginate(page: params[:page])
|
||||
@advisories = @advisories.includes(:platforms).search(params[:q]).
|
||||
uniq.paginate(page: params[:page])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.atom
|
||||
|
|
|
@ -13,6 +13,11 @@ class Advisory < ActiveRecord::Base
|
|||
ID_STRING_TEMPLATE = 'ROSA-%<type>s-%<year>04s:%<id>04s'
|
||||
TYPES = {'security' => 'SA', 'bugfix' => 'A'}
|
||||
|
||||
scope :search, lambda { |q|
|
||||
q = q.to_s.strip
|
||||
where("#{table_name}.advisory_id ILIKE :q OR #{table_name}.description ILIKE :q OR build_list_packages.fullname ILIKE :q", q: "%#{q}%").
|
||||
joins(build_lists: :packages) if q.present?
|
||||
}
|
||||
scope :search_by_id, lambda { |aid| where("#{table_name}.advisory_id ILIKE ?", "%#{aid.to_s.strip}%") }
|
||||
scope :by_update_type, lambda { |ut| where(update_type: ut) }
|
||||
default_scope order("#{table_name}.created_at DESC")
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
-# TODO: change filter to Backbone.js
|
||||
%th{colspan: 3, rowspan: 1}
|
||||
= form_tag advisories_path, method: :get do |f|
|
||||
= text_field_tag('q', params[:q], placeholder: t('layout.advisories.search_by_id'), class: params[:q].present? ? 'black' : 'gray', style: 'width:600px;')
|
||||
= text_field_tag('q', params[:q], placeholder: t('layout.advisories.search'), class: params[:q].present? ? 'black' : 'gray', style: 'width:600px;')
|
||||
= submit_tag t('layout.search.header'), data: {'disable-with' => t('layout.processing')}
|
||||
=# link_to t('layout.back'), advisories_path, class: 'button'
|
||||
= button_to t('layout.clear'), {action: :index} , method: :get
|
||||
|
|
|
@ -14,6 +14,7 @@ en:
|
|||
new: New
|
||||
existing: Existing
|
||||
search_by_id: Search advisory by it's ID
|
||||
search: Search advisory by it's ID, description or package name
|
||||
search_hint: Paste full AdvisoryID into text field or enter there its uniq part.
|
||||
advisory_id_info: AdvisoryID is a string %{advisory_format}, where 'XXXX' (at least 4 symbols) is a uniq part.
|
||||
publication_info: Advisory might be applied only to Build Lists with [%{update_types}] update types.
|
||||
|
|
|
@ -14,6 +14,7 @@ ru:
|
|||
new: Новый
|
||||
existing: Существующий
|
||||
search_by_id: Искать бюллетень по его ID
|
||||
search: Искать бюллетень по его ID, описанию или имени пакета
|
||||
search_hint: Скопируйте в поле ввода полный AdvisoryID или введите его уникальную часть
|
||||
advisory_id_info: AdvisoryID имеет формат %{advisory_format}, где 'XXXX' (минимум 4 символа) - это уникальная часть.
|
||||
publication_info: Бюллетень может быть присоединен только к сборочному листу с типами обновления %{update_types}.
|
||||
|
|
Loading…
Reference in New Issue