diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index 7aa77de28..625a63134 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -1,18 +1,10 @@ class Api::V1::MaintainersController < Api::V1::BaseController before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] - before_filter :find_platform + load_and_authorize_resource :platform def index @maintainers = BuildList::Package.actual.by_platform(@platform) - .order('lower(name) ASC, length(name) ASC') .includes(:project) .paginate(paginate_params) end - - private - - def find_platform - @platform = Platform.find(params[:platform_id]) - end - end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 386e48ae4..5c3e49a84 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -6,7 +6,6 @@ class Platforms::MaintainersController < ApplicationController def index @maintainers = BuildList::Package.actual.by_platform(@platform) - .order('lower(name) ASC, length(name) ASC') .includes(:project) @maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index ce894412b..6a3dcb79c 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -12,6 +12,8 @@ class BuildList::Package < ActiveRecord::Base :presence => true validates :package_type, :inclusion => PACKAGE_TYPES + default_scope order('lower(name) ASC, length(name) ASC') + # Fetches only actual (last publised) packages. scope :actual, where(:actual => true) scope :by_platform, lambda {|platform| where(:platform_id => platform) }