[refs #127] Filter request refactor
This commit is contained in:
parent
34b105675a
commit
0559f1b678
|
@ -14,20 +14,29 @@ class BuildListsController < ApplicationController
|
||||||
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
|
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
|
||||||
|
|
||||||
def index
|
def index
|
||||||
filter_params = params[:filter] || {}
|
if request.post?
|
||||||
if @project
|
new_params = {:filter => {}}
|
||||||
@action_url = project_build_lists_path(@project)
|
params[:filter].each do |k,v|
|
||||||
|
new_params[:filter][k] = v unless v.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to build_lists_path(new_params)
|
||||||
else
|
else
|
||||||
@action_url = build_lists_path
|
filter_params = params[:filter] || {}
|
||||||
end
|
if @project
|
||||||
|
@action_url = project_build_lists_path(@project)
|
||||||
|
else
|
||||||
|
@action_url = build_lists_path
|
||||||
|
end
|
||||||
|
|
||||||
@filter = BuildList::Filter.new(@project, filter_params)
|
@filter = BuildList::Filter.new(@project, filter_params)
|
||||||
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
|
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
|
||||||
|
|
||||||
@build_server_status = begin
|
@build_server_status = begin
|
||||||
BuildServer.get_status
|
BuildServer.get_status
|
||||||
rescue Exception # Timeout::Error
|
rescue Exception # Timeout::Error
|
||||||
{}
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class BuildList::Filter
|
||||||
def build_date_from_params(field_name, params)
|
def build_date_from_params(field_name, params)
|
||||||
if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
|
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,
|
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)
|
(params["#{field_name}(3i)"].presence || Date.today.day).to_i)
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%h2.title= t("layout.build_lists.filter_header")
|
%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
|
.columns.wat-cf
|
||||||
.column.left
|
.column.left
|
||||||
.group
|
.group
|
||||||
|
|
|
@ -42,6 +42,8 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
match 'build_lists', :via => :post, :to => 'build_lists#index', :as => 'build_lists'
|
||||||
|
|
||||||
resources :auto_build_lists, :only => [:index, :create, :destroy]
|
resources :auto_build_lists, :only => [:index, :create, :destroy]
|
||||||
|
|
||||||
resources :personal_repositories, :only => [:show] do
|
resources :personal_repositories, :only => [:show] do
|
||||||
|
|
Loading…
Reference in New Issue