From 22b8ce9e2c0a9771b6745cec1857394364b9d57c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 21 Mar 2014 02:56:59 +0400 Subject: [PATCH] #345: update build_lists_controller --- app/controllers/projects/base_controller.rb | 2 +- app/controllers/projects/build_lists_controller.rb | 4 +++- app/models/build_list/filter.rb | 2 +- app/models/build_list/item.rb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/projects/base_controller.rb b/app/controllers/projects/base_controller.rb index f9a0388bb..a360737a4 100644 --- a/app/controllers/projects/base_controller.rb +++ b/app/controllers/projects/base_controller.rb @@ -12,7 +12,7 @@ class Projects::BaseController < ApplicationController end 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 def init_statistics diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 42e443c72..16f8ca298 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -8,13 +8,15 @@ class Projects::BuildListsController < Projects::BaseController 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 except: NESTED_ACTIONS before_filter :create_from_build_list, only: :new def index + authorize!(:show, @project) if @project params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter] respond_to do |format| diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index 0ef09b86b..249b8eebc 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -9,7 +9,7 @@ class BuildList::Filter end def find - build_lists = @project ? @project.build_lists : BuildList.scoped + build_lists = @project ? @project.build_lists : BuildList.all if @options[:id] build_lists = build_lists.where(id: @options[:id]) diff --git a/app/models/build_list/item.rb b/app/models/build_list/item.rb index 10149c310..ad9fabd72 100644 --- a/app/models/build_list/item.rb +++ b/app/models/build_list/item.rb @@ -17,7 +17,7 @@ class BuildList::Item < ActiveRecord::Base 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 groups = []