diff --git a/app/models/ability.rb b/app/models/ability.rb index 3fe541d55..c9e9d8ab7 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -86,22 +86,22 @@ class Ability can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) } can [:autocomplete_user_uname, :read_advisories, :advisories], Platform - can([:failed_builds_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && (mass_build.platform.platform_type == 'main') } - can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && (mass_build.platform.platform_type == 'main')} + can([:failed_builds_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main? } + can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?} can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} can [:read, :projects_list], Repository, :platform => {:owner_type => 'User', :owner_id => user.id} can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform} can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform} - can(:clear, Platform) {|platform| local_admin?(platform) && platform.platform_type == 'personal'} + can(:clear, Platform) {|platform| local_admin?(platform) && platform.personal?} can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform} can :read, Product, :platform => {:visibility => 'open'} can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id, :platform_type => 'main'} can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids, :platform_type => 'main'} - can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.platform_type == 'main'} - can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.platform_type == 'main'} + can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.main?} + can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.main?} can(:create, ProductBuildList) {|pbl| can?(:update, pbl.product)} can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)} @@ -132,8 +132,8 @@ class Ability cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'} cannot [:clone], Platform, :platform_type => 'personal' - cannot([:failed_builds_list, :create], MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'} - cannot(:cancel, MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal' || mass_build.stop_build} + cannot([:failed_builds_list, :create], MassBuild) {|mass_build| mass_build.platform.personal?} + cannot(:cancel, MassBuild) {|mass_build| mass_build.platform.personal? || mass_build.stop_build} can :create, Subscribe do |subscribe| !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) diff --git a/app/models/platform.rb b/app/models/platform.rb index 892a093e7..ddfadd1ee 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -107,6 +107,10 @@ class Platform < ActiveRecord::Base platform_type == 'personal' end + def main? + platform_type == 'main' + end + def base_clone(attrs = {}) # :description, :name, :owner dup.tap do |c| attrs.each {|k,v| c.send("#{k}=", v)} # c.attributes = attrs