[#123] show additional platforms where user is member of platform repository

This commit is contained in:
Alexander Machehin 2013-05-17 16:26:02 +06:00
parent 70a2705405
commit 8b0b81665d
2 changed files with 2 additions and 0 deletions

View File

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

View File

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