From 8b0b81665d4fbc137bb63b3b30dcf2b4ea57082b Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 17 May 2013 16:26:02 +0600 Subject: [PATCH] [#123] show additional platforms where user is member of platform repository --- app/models/ability.rb | 1 + app/models/user.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/ability.rb b/app/models/ability.rb index 016bf062d..3fef4fa94 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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) } diff --git a/app/models/user.rb b/app/models/user.rb index 9b29dc37f..a53f530e1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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