Merge pull request #138 from abf/rosa-build:123-show_more_user_platforms
[refs #123] show more user platforms
This commit is contained in:
commit
8c02db6847
|
@ -6,7 +6,7 @@ class Platforms::PlatformsController < Platforms::BaseController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
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
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -99,6 +99,7 @@ class Ability
|
||||||
can [:read, :owned, :related, :members], Platform, :owner_type => 'User', :owner_id => user.id
|
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, :owner_type => 'Group', :owner_id => user.group_ids
|
||||||
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
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([:update, :destroy], Platform) {|platform| owner?(platform) }
|
||||||
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ class User < Avatar
|
||||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
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 :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
||||||
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :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_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
||||||
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
|
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
|
||||||
|
|
Loading…
Reference in New Issue