This commit is contained in:
vladdruzh 2012-11-28 10:04:40 +04:00
parent c42fcc824a
commit 0545863642
3 changed files with 3 additions and 10 deletions

View File

@ -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

View File

@ -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])

View File

@ -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) }