#766: add filter to /build_lists page

This commit is contained in:
Vokhmin Alexey V 2012-12-10 16:15:22 +04:00
parent c677e37c20
commit 62a761a7c9
4 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,13 @@ module BuildListsHelper
'nocolor'
end
def build_list_options_for_new_core
[
[I18n.t("layout.true_"), 1],
[I18n.t("layout.false_"), 0]
]
end
def build_list_item_status_color(status)
if BuildServer::SUCCESS == status
return 'success'

View File

@ -112,6 +112,7 @@ class BuildList < ActiveRecord::Base
s
}
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
scope :scoped_to_new_core, lambda {|new_core| where(:new_core => new_core)}
scope :outdated, where('created_at < ? AND status <> ? OR created_at < ?', Time.now - LIVE_TIME, BUILD_PUBLISHED, Time.now - MAX_LIVE_TIME)
serialize :additional_repos

View File

@ -13,6 +13,7 @@ class BuildList::Filter
build_lists = build_lists.where(:bs_id => @options[:bs_id])
else
build_lists = build_lists.accessible_by(::Ability.new(@user), @options[:ownership].to_sym) if @options[:ownership]
build_lists = build_lists.scoped_to_new_core(@options[:new_core] == '0' ? nil : true) if @options[:new_core].present?
build_lists = build_lists.for_status(@options[:status]) if @options[:status]
build_lists = build_lists.scoped_to_arch(@options[:arch_id]) if @options[:arch_id]
build_lists = build_lists.scoped_to_save_platform(@options[:platform_id]) if @options[:platform_id]
@ -49,7 +50,8 @@ class BuildList::Filter
:project_version => nil,
:bs_id => nil,
:project_name => nil,
:mass_build_id => nil
:mass_build_id => nil,
:new_core => nil
}))
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned')
@ -65,6 +67,7 @@ class BuildList::Filter
@options[:bs_id] = @options[:bs_id].presence
@options[:project_name] = @options[:project_name].presence
@options[:mass_build_id] = @options[:mass_build_id].presence
@options[:new_core] = @options[:new_core].presence
end
def build_date_from_params(field_name, params)

View File

@ -37,6 +37,8 @@
%br
= f.submit t("layout.search.header")
.block
%h3.small= t("activerecord.attributes.build_list.new_core")
.lineForm.aside= f.select :new_core, build_list_options_for_new_core, {:include_blank => true, :selected => @filter.new_core}, {:class => 'sel80 aside', :id => 'new_core', :tabindex => 2}
%h3.small= t("activerecord.attributes.build_list.status")
.lineForm.aside= f.select :status, BuildList::STATUSES.collect{|status| [BuildList.human_status(status), status]}, {:include_blank => true, :selected => @filter.status}, {:class => 'sel80 aside', :id => 'status', :tabindex => 2}
%h3.small= t("activerecord.models.platform")