Merge pull request #138 from abf/rosa-build:123-show_more_user_platforms

[refs #123] show more user platforms
This commit is contained in:
warpc 2013-05-17 18:07:24 +04:00
commit 8c02db6847
3 changed files with 3 additions and 1 deletions

View File

@ -6,7 +6,7 @@ class Platforms::PlatformsController < Platforms::BaseController
load_and_authorize_resource
def index
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
@platforms = @platforms.accessible_by(current_ability, :related).order(:name).paginate(:page => params[:page], :per_page => 20)
end
def show

View File

@ -99,6 +99,7 @@ class Ability
can [:read, :owned, :related, :members], Platform, :owner_type => 'User', :owner_id => user.id
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
can :related, Platform, :id => user.repositories.pluck(:platform_id)
can([:update, :destroy], Platform) {|platform| owner?(platform) }
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }

View File

@ -24,6 +24,7 @@ class User < Avatar
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository'
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy