#345: update build_lists_controller

This commit is contained in:
Vokhmin Alexey V 2014-03-21 02:56:59 +04:00
parent 61bcfb9e4e
commit 22b8ce9e2c
4 changed files with 6 additions and 4 deletions

View File

@ -12,7 +12,7 @@ class Projects::BaseController < ApplicationController
end end
def find_project def find_project
@project = Project.find_by_owner_and_name! params[:name_with_owner] @project = Project.find_by_owner_and_name! params[:name_with_owner] if params[:name_with_owner].present?
end end
def init_statistics def init_statistics

View File

@ -8,13 +8,15 @@ class Projects::BuildListsController < Projects::BaseController
before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container] before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container]
load_and_authorize_resource :project, only: NESTED_ACTIONS load_and_authorize_resource :project, only: [:new, :create]
load_resource :project, only: :index, parent: false
load_and_authorize_resource :build_list, through: :project, only: NESTED_ACTIONS, shallow: true load_and_authorize_resource :build_list, through: :project, only: NESTED_ACTIONS, shallow: true
load_and_authorize_resource except: NESTED_ACTIONS load_and_authorize_resource except: NESTED_ACTIONS
before_filter :create_from_build_list, only: :new before_filter :create_from_build_list, only: :new
def index def index
authorize!(:show, @project) if @project
params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter] params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter]
respond_to do |format| respond_to do |format|

View File

@ -9,7 +9,7 @@ class BuildList::Filter
end end
def find def find
build_lists = @project ? @project.build_lists : BuildList.scoped build_lists = @project ? @project.build_lists : BuildList.all
if @options[:id] if @options[:id]
build_lists = build_lists.where(id: @options[:id]) build_lists = build_lists.where(id: @options[:id])

View File

@ -17,7 +17,7 @@ class BuildList::Item < ActiveRecord::Base
BuildList::BUILD_CANCELED => :build_canceled BuildList::BUILD_CANCELED => :build_canceled
} }
scope :recent, order("#{table_name}.level ASC, #{table_name}.name ASC") scope :recent, -> { order("#{table_name}.level ASC, #{table_name}.name ASC") }
def self.group_by_level def self.group_by_level
groups = [] groups = []