Merge pull request #1132 from okriuchykhin/ok_SCI_2301

Move REPOSITORIES_LIMIT from constants to env variables [SCI-2301]
This commit is contained in:
okriuchykhin 2018-05-10 10:46:25 +02:00 committed by GitHub
commit 3b4d9fe744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 7 deletions

View file

@ -44,7 +44,8 @@ class AtWhoController < ApplicationController
end
def repositories
repositories = @team.repositories.limit(Constants::REPOSITORIES_LIMIT)
repositories =
@team.repositories.limit(Rails.configuration.x.repositories_limit)
respond_to do |format|
format.json do
render json: {

View file

@ -300,8 +300,10 @@ class RepositoriesController < ApplicationController
end
def check_create_permissions
render_403 unless can_create_repositories?(@team) ||
@team.repositories.count < Constants::REPOSITORIES_LIMIT
unless can_create_repositories?(@team) ||
@team.repositories.count < Rails.configuration.x.repositories_limit
render_403
end
end
def check_manage_permissions

View file

@ -44,7 +44,7 @@ Canaid::Permissions.register_for(Team) do
# repository: create, copy
can :create_repositories do |user, team|
user.is_admin_of_team?(team) &&
team.repositories.count < Constants::REPOSITORIES_LIMIT
team.repositories.count < Rails.configuration.x.repositories_limit
end
# repository: create/import record

View file

@ -58,9 +58,6 @@ class Constants
# Max characters for repository name in Atwho modal
ATWHO_REP_NAME_LIMIT = 16
# Maximum number of repositories per team allowed
REPOSITORIES_LIMIT = 5
#=============================================================================
# File and data memory size
#=============================================================================

View file

@ -0,0 +1,4 @@
Rails.application.configure do
# Maximum number of repositories per team allowed
config.x.repositories_limit = ENV['REPOSITORIES_LIMIT'].to_i || 5
end