[refs #127] Filter request refactor

This commit is contained in:
konstantin.grabar 2012-02-01 20:00:19 +04:00
parent 34b105675a
commit 0559f1b678
4 changed files with 24 additions and 13 deletions

View File

@ -14,20 +14,29 @@ class BuildListsController < ApplicationController
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
def index
filter_params = params[:filter] || {}
if @project
@action_url = project_build_lists_path(@project)
if request.post?
new_params = {:filter => {}}
params[:filter].each do |k,v|
new_params[:filter][k] = v unless v.empty?
end
redirect_to build_lists_path(new_params)
else
@action_url = build_lists_path
end
filter_params = params[:filter] || {}
if @project
@action_url = project_build_lists_path(@project)
else
@action_url = build_lists_path
end
@filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@build_server_status = begin
BuildServer.get_status
rescue Exception # Timeout::Error
{}
@build_server_status = begin
BuildServer.get_status
rescue Exception # Timeout::Error
{}
end
end
end

View File

@ -68,7 +68,7 @@ class BuildList::Filter
def build_date_from_params(field_name, params)
if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
Date.civil((params["#{field_name}(1i)"].presence || Date.today.year).to_i,
(params["#{field_name}(2i)"].presence || Date.today.mohth).to_i,
(params["#{field_name}(2i)"].presence || Date.today.month).to_i,
(params["#{field_name}(3i)"].presence || Date.today.day).to_i)
else
nil

View File

@ -1,6 +1,6 @@
%h2.title= t("layout.build_lists.filter_header")
= form_for :filter, :url => @action_url, :html => { :method => :get, :class => :form } do |f|
= form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
.columns.wat-cf
.column.left
.group

View File

@ -42,6 +42,8 @@ Rosa::Application.routes.draw do
end
end
match 'build_lists', :via => :post, :to => 'build_lists#index', :as => 'build_lists'
resources :auto_build_lists, :only => [:index, :create, :destroy]
resources :personal_repositories, :only => [:show] do